AS3 Random Number Generator Code – ActionScript 3.0 Tutorial
Mar.01, 2011 in
ActionScript
An ActionScript 3.0 random number generation script for use in Flash or Flex.
Video Rating: 4 / 5
Free Source – www.developphp.com Learn how to create operating system style windows for your flash actionscript 3.0 projects. We make sure that the window top bar is the only thing that can be grabbed and dragged around to produce the effect we want. To see how I used it on my site check out www.flashbuilding.com
Video Rating: 5 / 5
Incoming search terms:
- shell energy efficiency
- AS3 Random Number Generator Code - ActionScript 3 0 Tutorial
Related posts:
- Flash Tutorial :: Learn how to ActionScript! Scripting 101
- The Essential Guide to Flex 2 with ActionScript 3.0 (Essentials)
- XML Magic Menu Tutorial for ActionScript 3 Flash CS3 + CS4
- Flash Tutorial: Creating a Clock/Calendar with Actionscript 3.0
- Foundation ActionScript 3.0 for Flash and Flex (Foundations)

March 1st, 2011 at 2:23 pm
@Petse123321 I wrote that comment 6 months ago, you have no idea how much I’ve progressed since that, but thanks for the help anyway
March 1st, 2011 at 3:17 pm
@coolguyflex
Math.floor(Math.random()*4 – 2)
This will create a number between 0 and 4 and then substract 2 from it creating number between -2 and 2.
March 1st, 2011 at 3:41 pm
Well, I guess I should specify that I created a button and used actionscript 3 to run the function. It works in the browser and previews, but not in the stand alone player.
March 1st, 2011 at 3:59 pm
So, I can see this generator work all day long in preview and in the browser, but when I save to SWF and try to play it in just a player, nothing happens. Is there something that I’m missing?
March 1st, 2011 at 4:19 pm
How can i get a number between 2 and -2;
March 1st, 2011 at 4:46 pm
Thanks for the many invaluable tutorials you’ve take the time to upload Adam!
I have a brief question, Is it possible to make the generator non-repeating using this implementation?
March 1st, 2011 at 5:08 pm
@sixthcrusifix
Math.floor(Math.random() * 626) + 250;
March 1st, 2011 at 5:35 pm
That’s great but what if I want a random number between 250 and 875?
Can Actionscript seriously not do this? I can only have numbers between 1 (or 0) and something?
March 1st, 2011 at 6:00 pm
a question:
can you use this to display text, rather than numbers? as in using if / else statements?
if so, what would the code look like, if the base code is:
var randNum:Number = Math.floor(Math.random() * 10) + 1;
status_txt.text = “”+randNum;
thank you for posting these tutorials!!
March 1st, 2011 at 6:39 pm
its better to do it in flash because you don’t need to install a program for it!
March 1st, 2011 at 7:00 pm
Very sweeeet!!!!! Love it!
March 1st, 2011 at 7:09 pm
thank u adam
but can u do a small tutoriels about a simple webpage designed on flash
March 1st, 2011 at 7:18 pm
I made a program that could do that
March 1st, 2011 at 7:42 pm
Thanks
March 1st, 2011 at 8:20 pm
thanks man. very nice
March 1st, 2011 at 8:48 pm
awesome adam. that is nice to integrate with php and create the login verification
March 1st, 2011 at 9:04 pm
//AS2 equivalent to this tutorial’s code – Part 2:
window1.dragBar.onPress = function() {
window1.startDrag(false, rectX, rectY, rectX+boundWidth, rectY+boundHeight);
};
window1.dragBar.onRelease = function() {
window1.stopDrag();
};
window1.dragBar.onReleaseOutside = function() {
window1.stopDrag();
};
March 1st, 2011 at 9:59 pm
//AS2 equivalent to this tutorial’s code – Part 2:
window1.dragBar.onPress = function() {
window1.startDrag(false, rectX, rectY, rectX+boundWidth, rectY+boundHeight);
};
window1.dragBar.onRelease = function() {
window1.stopDrag();
};
window1.dragBar.onReleaseOutside = function() {
window1.stopDrag();
};
March 1st, 2011 at 10:19 pm
AS2 equivalent to this tutorial’s code – Part 2:
window1.dragBar.onPress = function() {
window1.startDrag(false, rectX, rectY, rectX+boundWidth, rectY+boundHeight);
};
window1.dragBar.onRelease = function() {
window1.stopDrag();
};
window1.dragBar.onReleaseOutside = function() {
window1.stopDrag();
};
March 1st, 2011 at 10:32 pm
AS2 equivalent to this tutorial’s code - Part 2:
window1.dragBar.onPress = function() {
window1.startDrag(false, rectX, rectY, rectX+boundWidth, rectY+boundHeight);
};
window1.dragBar.onRelease = function() {
window1.stopDrag();
};
window1.dragBar.onReleaseOutside = function() {
window1.stopDrag();
};
March 1st, 2011 at 10:43 pm
AS2 equivalent to this tutorial’s code - Part 2:
window1.dragBar.onPress = function() {
window1.startDrag(false, rectX, rectY, rectX+boundWidth, rectY+boundHeight);
};
window1.dragBar.onRelease = function() {
window1.stopDrag();
};
window1.dragBar.onReleaseOutside = function() {
window1.stopDrag();
};
March 1st, 2011 at 11:31 pm
I WANT AS2, AS3 SUXXXX
March 1st, 2011 at 11:54 pm
He is one hell of a loser himself don’t worry about him
March 2nd, 2011 at 12:47 am
your website isso cool!
March 2nd, 2011 at 1:42 am
The Best Tutorial Ever !!!!!
March 2nd, 2011 at 2:39 am
Thank you so much for the tutorial. Very nice, been learning a lot from them.
I did have one small problem that I fixed myself. If you were to drag the window to fast, then cursor becomes detached from the window, and then you would have to reclick and start draging again. Don’t know if you get that.
I fixed it by removing line number 21. Don’t rely think you need that line. Problem gone.
Very cool vids, thank you so much.
March 2nd, 2011 at 2:47 am
timeline scripting is for losers.
March 2nd, 2011 at 2:54 am
awesome tutorial i needed that,thanks
March 2nd, 2011 at 3:53 am
keep up the good work!!!
March 2nd, 2011 at 4:01 am
March 2nd, 2011 at 5:01 am
great man
March 2nd, 2011 at 5:20 am
great tut….5stars
March 2nd, 2011 at 5:22 am
that’s so cool!