Simple question (probably)

I just have one quick question. As I have been going through the new flash mx book advanced actionscript from the source I have noticed instances where instead of using the regular “=” sign they use the “==” sign but, they negate mentioning why or when to use each particular instance. (example below)

Can someone elaborate on this?

thanks ahead of time!



MovieClip.prototype.flip = function(mode){
   if (mode.toLowerCase() == “h”){
      this._xscale = -this._xscale;
   }else if (mode.toLowerCase() == “v”){
      this._yscale = -this._yscale;

that is a good question with a simple answer.

= assigns value to something. For example age=23. If you Trace(age);
The result would be 23.

== compares values (as in Boolean operation) and returns True or false. If you trace(age==23); It would return true or flase, depending on the value of age.

so… in my code I have

Guess someones age.

var age=23; //asigns 23 to age

trace(“you guessed it!”);
} else{
trace(“try again!”);

hope that helps


I knew there was a “good” reason :slight_smile:

Odd it wasn’t explained in the book, guess it was implied. Anyway thanks again.


I said that the operator == had not been explained in the book but, actually it is explained along with the other operators used in conditional logic. Its just later in the book. I guess they figured it wasn’t necessary to know until half-way through.

anyway just thought I’d give the authors credit.