[vet-mm] FLASH ActionScript 3.0 Buttons

Kevork Krozian Kroset at novell1.fhc.vic.edu.au
Tue Feb 17 10:13:37 EST 2009


Hi Folks,

 The great aspect to jumping to a random frame is that you can play a multitude of games eg. Give me a random card face from a set of 10 faces one per frame. If you have 3 cards adjacent you could play a poker machine game as long as the students are given sufficient warnings about the hazards of gambling. Or a set of 6 die ( dice ) faces to return a random face ; double it and you could have a pair of dice that could be used to play a game such as backgammon ..... Great potential !


Take Care



Kevork Krozian
IT Manager , Forest Hill College
k.krozian at fhc.vic.edu.au
http://www.fhc.vic.edu.au
Mobile: 0419 356 034

>>> <peterfowler at optusnet.com.au> 16/02/2009 3:20 pm >>>
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
_______________________________________________
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