Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-11-2012, 08:55 PM   #1
Join Date: Feb 2012
Location: I´m bad at English...
Posts: 84
Lightbulb Translate to AS3

Could you please translate this code to as3 and explain the new one to me, please?
ActionScript Code:
gotoAndPlay(random(20) + 25);
TheMrKiko is offline  
Old 05-11-2012, 09:00 PM   #2
Senior Member
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,812
Send a message via AIM to abeall

ActionScript Code:
gotoAndPlay((Math.random() * 20) + 25);

Explanation: the only difference is that random() -- which was deprecated even in AS2 -- is removed. Math.random() existed in AS2 and behaves the same in AS3.

You can replicate random() very easily, too:

ActionScript Code:
function random(num:int):int {     return Math.random() * num; }
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter

Last edited by abeall; 05-11-2012 at 09:02 PM.
abeall is offline  
Closed Thread

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 04:22 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.