[vet-mm] Actionscript 3.0 Randomise

Kevork Krozian Kroset at novell1.fhc.vic.edu.au
Wed Dec 3 16:49:31 EST 2008


Good point Rob

Thanks
Kevork

>>> "Rob Swain" <RSwain at gordontafe.edu.au> 3/12/2008 3:52 pm >>>
To avoid getting a reference to frame 0 which doesn't exist, try

gotoAndPlay((Math.floor(Math.random()*24))+1);


Rob Swain
Interactive Digital Media | Gordon Institute of TAFE




-----Original Message-----
From: vet-mm-bounces at edulists.com.au 
[mailto:vet-mm-bounces at edulists.com.au] On Behalf Of Kevork Krozian
Sent: Wednesday, 3 December 2008 2:42 PM
To: vet-mm at edulists.com.au 
Subject: Re: [vet-mm] Actionscript 3.0 Randomise

Hi Travis,

 I am quoting from http://www.kirupa.com/forum/showthread.php?p=2112823 

"  Like random(), Math.random() is used to produce random numbers,
however it functions slightly differently. Instead of providing a whole
number between 0 and up to but not including the number you pass into
random(), Math.random() instead returns a random decimal value between 0
and 1 without any need to pass it any value. If you want to have
Math.random behave like random, you need to use the following command
where n is the number you would have passed into a call to random();
   Math.floor(Math.random()*n); // = random(n) 


So , Math.floor cuts off any decimal value returned and just preserves
the whole number part. And Math.random() returns a value between 0 and
1. When multiplied by n eg. 25 and value returned is 0 to 1 times 25 = 0
to 25 ( no decimal part achieved by Math.floor ).

So replace the gotoAndPlay(random(25)); by

gotoAndPlay( Math.floor(Math.random()*25));



 Good luck





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

>>> "Travis Parker" <tparker at sjrc.melb.catholic.edu.au> 3/12/2008 1:58 
>>> pm >>>
Guys,

Am currently writing the course for next year's Cert III students. As we
did Actionscript 3.0 this year, I would like to continue with it so as
to not disrupt the students' preparation. I am trying to make a flash
document with a button for interactivity that takes them to a random
frame (We covered interactive flash documents this year that jump to
pre-determined frames).

Here is the code I used to jump between frames (Used for a multi-choice
game):

start_btn.addEventListener(MouseEvent.CLICK, ask);

function ask(event:MouseEvent) :void {
gotoAndPlay("Question");
}

Here is what I have for actionscript 2.0 to jump to random frames:

on (release) {
gotoAndPlay(random ( 25 ));
}

I realise that there is no randomise function in Actionscript 3.0.

Is there anyone out there with a solution to this or should I just not
try it?!?!?

Many thanks and happy holidays

Trav



--
This e-mail and any attachments may be confidential. If you are not the
addressee indicated in this message (or responsible for delivery of the
message to such person), you may not copy or deliver this message to
anyone, and you should destroy this message and kindly notify the sender
by reply e- mail. St John's Regional College does not represent or
warrant that the attached files are free from computer viruses or other
defects. The attached files are provided, and may only be used, on the
basis that the user assumes all responsibility for any loss, damage or
consequence resulting directly or indirectly from the use of the
attached files, whether caused by the negligence of the sender or not.
The liability of St John's Regional College is limited in any event to
either the resupply of the attached files or the cost of having the
attached files resupplied. Any representations or opinions expressed in
this e-mail are those of the individual sender, and not necessarily
those of St John's Regional College.
_______________________________________________
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

******************************************************************************
**** NOTICE FROM Gordon Institute of TAFE ****
This message is confidential, and may contain proprietary or legally privileged information. If you have received this email in error, please notify the sender and delete it immediately. Please take appropriate precautions when communicating across the internet. The Gordon Institute of TAFE under no circumstances accepts liability for any loss or damage which may result from your receipt of this message or any attachments.
******************************************************************************


_______________________________________________
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