AS3 to Arduino - Passing Strings

change this

while(Serial.available() == 0);
  
  //readCommand();
  //Serial.println(command);
  
  
  readCommand();

to

if(Serial.available() > 0) 
{
readCommand();
}

this

while (!Serial.available())
			;
		c = Serial.read();

to

while(Serial.available() > 0)
{
c = Serial.read();
		if (c == '\r' || c == '\n') {
			break;
		}
		commandBuffer[i] = c;
		i++;
}