You should use the chmod command as root user or as a sudoer (sudo chmod ...) otherwise it fails. If you use:
sudo chmod 755 /path/to/flex
the permission reflects only on the 'flex' directory. If you want to set the permission to all of his (flex) child files and directories you should use the '-R' option, which stands for recursively. In this case your command will like this:
sudo chmod -R 755 /path/to/flex