Gina Gina - 4 months ago 23
ActionScript Question

Adobe flash professional color switch on frames

I need to make a simple app using adobe flash professional.

I have on frame 1 a red square and on frame 2 the same square blue.

When I press on that square I need to make the square blue, I mean I have to go to frame 2. This is like a color switch.
Do you have any ideea?
Thank you in advance.

Answer

On each of your frames ensure the code

stop();

has been added.

Then, in your first frame add:

stage.addEventListener(MouseEvent.CLICK,gotoFrame2);
function gotoFrame2(e:MouseEvent){
      gotoAndStop(2);
}

Inside your second frame under 'stop()' add:

stage.addEventListener(MouseEvent.CLICK,gotoFrame1);
function gotoFrame1(e:MouseEvent){
      gotoAndStop(1);
}

A safer option is to called you frames names in the properties panel, then in the gotoAndStop function you can call the string - this saves the potential glitches if you modify frame locations.

e.g:

gotoAndStop("MyHomePage")

Good luck!