AS3 need advice scripting

A place for tutorials on how to get the most out of Flash

AS3 need advice scripting

Postby Mr D » Fri Jun 26, 2015 2:35 am

Hello there. I would like some advice. Here is my problem.
I have a "scene" and on it is movie clip "Y" (inst. name Y).
Clip Y has frame 1,2 and 3.
I need 3 different buttons that are on "scene" to gotoAndStop on frame 1,2,3 in clip Y (inst name for buttons B1,B2,B3).

I did try to look around for the right code but since I do not really understand it I only ended with many failures that did nothing. Please help.

picture if I was not clear.
Spoiler (click to show/hide):

HELP.jpg
1 game (oh I mean story slideshow -_-) and 5 flash loop FINISHED...fuck yea
My mini flashes link : http://legendofkrystal.com/forum/viewto ... f=7&t=1972
Also I am working on a project right now.But remember, it's a secret to everybody >:D
User avatar
Mr D
 
Joined: Tue Jun 01, 2010 12:44 am
Location: Alphabet

Re: AS3 need advice scripting

Postby GoRepeat » Fri Jun 26, 2015 6:07 pm

Code: Select All Code
addEventListener(MouseEvent.CLICK, sceneClick);

function sceneClick(e:MouseEvent):void{
     switch(true){
           case e.target.name=="B1": Y.gotoAndStop(1); break;
           case e.target.name=="B2": Y.gotoAndStop(2); break;
           case e.target.name=="B3": y.gotoAndStop(3); break;
     }
}
Picarto LiveStream: https://picarto.tv/GoRepeat
Other Stuff: Click Here
User avatar
GoRepeat
Moderator
 
Joined: Wed Jul 21, 2010 2:26 am
Location: Behind the Looking Glass

Re: AS3 need advice scripting

Postby Mr D » Fri Jun 26, 2015 6:24 pm

It worked and from the way you wrote It, I can even understand how it works. Thank you very much gorepete.
1 game (oh I mean story slideshow -_-) and 5 flash loop FINISHED...fuck yea
My mini flashes link : http://legendofkrystal.com/forum/viewto ... f=7&t=1972
Also I am working on a project right now.But remember, it's a secret to everybody >:D
User avatar
Mr D
 
Joined: Tue Jun 01, 2010 12:44 am
Location: Alphabet

Re: AS3 need advice scripting

Postby GoRepeat » Sat Jun 27, 2015 8:44 pm

Mr D Wrote:It worked and from the way you wrote It, I can even understand how it works. Thank you very much gorepete.



:D
Picarto LiveStream: https://picarto.tv/GoRepeat
Other Stuff: Click Here
User avatar
GoRepeat
Moderator
 
Joined: Wed Jul 21, 2010 2:26 am
Location: Behind the Looking Glass

Re: AS3 need advice scripting

Postby NoBounce16 » Sat Feb 13, 2016 11:54 pm

Although this is a great method to do it, I worry that it's not very future proof. The best way of doing this would be to create an 'animation' class, which inherits MovieClip and has information on how many frames are inside it. I'd also create a button class that asks for a Sprite property and a 'gotoframe' property. That way, in the future you can create lots of different animations and buttons that can interact with each other without having to hardcode switch statements for all of your buttons. Let me know if this makes sense.
NoBounce16
Newly Registered
 
Joined: Thu Feb 11, 2016 11:38 am


Return to Tutorials



Who is online

Users browsing this forum: No registered users