Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help converting AS3 code to AS2

Status
Not open for further replies.

Dweezel

Technical User
Feb 12, 2004
428
GB
I'd like to do something that is very elementary, but not knowing actionscript 2 I'm having problems.

This is what I want to do.

1, Scene begins with no animation, and event listener is added to go_mc.
2, go_mc movieclip is clicked and a gotoAndPlay('first_event') is triggered.
3, After about 50 frames the animation is stopped and the event listener previously added to go_mc is removed.
4. New event listener is added to go_mc so that when it is clicked next time it will gotoAndPlay('second_event').


So basically I want to add an eventlistener to a movieclip, remove it at some point and then add a different event listener.

Here's how I might do it in AS3:

On frame 0
Code:
stop();

go_mc.addEventListener(MouseEvent.CLICK, first_event)

function first_event(event:MouseEvent):void
{ gotoAndPlay('first_one'); }

buttonMode = true;


On frame 50
Code:
stop();
go_mc.removeEventListener(MouseEvent.CLICK, first_event);

go_mc.addEventListener(MouseEvent.CLICK, second_event)

function second_event(event:MouseEvent):void
{ gotoAndPlay('second_one'); }

I could use one function and send the label name into it, but you get the idea.

Could anyone help me with converting this into AS2 please?

TIA,

Chris.
 
For anyone with a similar problem. This is the code I got to work in AS2 in the end:

frame 0
Code:
stop();

go_mc.onPress = function(){gotoAndPlay('first_event');}

frame 50
Code:
stop();

go_mc.onPress = function(){gotoAndPlay('second_event');}


Chris.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top