[vet-mm] FLASH ActionScript 3.0 Buttons

peterfowler at optusnet.com.au peterfowler at optusnet.com.au
Mon Feb 16 15:20:45 EST 2009


Hi Ray,
If you want the button to take you to an exact frame you would use the following code on the first frame of an empty layer( nav_btn is the instance name of the button, and nav_to the name of the function you are calling)

nav_btn.addEventListener(MouseEvent.CLICK, nav_to);

function nav_to(event:MouseEvent) :void {
gotoAndPlay(2);
}

You still use stop(); to stop the playhead advancing.
However if you want the button to take you to a random frame number when you click it you would use the code below (12 is the number of frames on the timeline you can select from. That is an arbitrary number of frames that I chose but could be any amount)


nav_btn.addEventListener(MouseEvent.CLICK, nav_to);

function nav_to(event:MouseEvent) :void {
gotoAndPlay((Math.floor(Math.random()*12))+1);
}

I hope that is what you needed. 
Good luck.
Peter Fowler
Swinburne Senior Secondary College





> Raymond Nashar <rnashar at msj.melb.catholic.edu.au> wrote:
> 
> Hi,
> 
> I'm trying to give buttons the ability to navigate to different frames  
> in a timeline.
> 
> I'm used to using behaviors in ActionScript 2.0.
> 
> How is it done in ActionScript 3.0?
> 
> Does anyone have a simple example or fla file to share?
> 
> Thanks heaps in advance!
> 
> -Ray
> 
> 
> 
> Raymond Nashar
> eLearning Coordinator
> 
> Mount Saint Joseph Girls' College
> 133 Maidstone Street
> Altona, Victoria, Australia 3018
> 
> p :: 03 8398 2000
> f :: 03 9398 3498
> w :: www.msj.melb.catholic.edu.au
> 
> _______________________________________________
> http://www.edulists.com.au - FAQ, resources, subscribe, unsubscribe
> VET Multimedia Mailing List kindly supported by
> http://www.vcaa.vic.edu.au/vet/programs/multimedia/multimedia.html - 
> Victorian Curriculum and Assessment Authority and
> http://www.pixeled.org.au  - PixelEd Multimedia Teachers Association


More information about the vet-mm mailing list