ActionScript 2.0 :: Selecting Random Number From Variable

May 30, 2010

So what I have here is a button that will take away a random number from a variable (in this case being money) this is nothing more than a learning experience and I just wish to broaden my horizons on flash AS.

Actionscript Code:
on (release) { money -= random(200); }on (release) {gotoAndPlay (2);}
While this code works just fine the only problem i have with it is that it will select a number from (0-200). Is there a way I can set this up to select a random number BETWEEN 2 numbers? EX: (150-200)

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Do A Math.random On Selecting A Certain Number Of XML Items?

Jul 5, 2009

anyway to do a Math.random on selecting a certain number of XML items?

View 8 Replies

ActionScript 2.0 :: Random Number - Click On A Button The Variable Number?

Sep 18, 2005

lets say that when you click on a button the variable number goes up 1 or 2 but it picks it randomly
how would i do it

[Code]...

View 8 Replies

ActionScript 2.0 :: When A Specific Variable Equals A Specific Value A Random Number Decreases On The Current Number?

Feb 20, 2008

i have a project and i need that when a specific variable equals a specific value a random number decreases on the current number, its easy to make it decrease but i need to decrease instead of 4 to decrease a maximun of 5 and minimun of 3.ere is the code :

Code:

numeroDeTazos = 20;
quantidade.text = numeroDeTazos;
if (nrfinal2 == 33)
{

[code]....

View 1 Replies

ActionScript 2.0 :: Putting Data Into An Array Via XML And Then Selecting At Random An Image String To Load In A Pic At Random

Feb 11, 2009

I've been putting data into an array via XML, and then selecting at random an image string to load in a pic at random. But whilst doing this, I wanted to remove the String from the Array that I have just used, so I don't get repetition of the same image in the output. I initially thought that pop would remove the string I had just used - But of course it Removes the last value in the Array instead, which doesn't really help.

Ok - so how about randomizing the data once inside the Array, after it has been pulled in from XML!? That way I can load in the 'last' image, and then pop it out! Keeping a randomized selection of images each time 'it' is loaded

View 2 Replies

ActionScript 3.0 :: Random Number Variable?

Jan 9, 2010

Im trying to do a hittest on a random movieclip... basically i have 4 'objects' and i am picking a random number to pick one of them... this is all fine except when i try to do a hittest on 'object' + randomNum...Below is the code that works first with a trace that is kicking out the name i want, and below is the code ive tried but doesnt work...

Code:
var randomNum:Number;
randomNum = Math.round(Math.random()*3)+1;[code].......

View 2 Replies

IDE :: Change Random Number Variable To Sequence?

Aug 20, 2009

the variable Im interested in is numSound which at the moment is a random number between 1 and 5, but it repeats too much and a sequence would be fine. I know very little actionscript and nothing I have tried works,the code, or what seems the relevant code, is

Code:
private function randRange(min:Number, max:Number):Number
{

[code].....

View 2 Replies

ActionScript 2.0 :: Change Random Number Variable To Sequence?

Aug 17, 2009

I want to change this bit of code

var numSound:Number = randRange(1, 5);

which I presume creates a random number between 1 and 5, to just a simple sequence of 1 to 5, or alternately, random would be ok if there was a way to preventing it from repeating numbers

View 9 Replies

ActionScript 2.0 :: Choosing Random Number And Put In Variable Form?

Dec 1, 2009

How to do math calculations in AS2? I only need + and -. Aswell, how to choose a random number inbetween 2 and 6 and put in a variable form. After this, I need to do a calculation like:
Code:
"currenthealth" - "random"

View 1 Replies

ActionScript 2.0 :: Generate A Variable Number Of Random Numbers?

Nov 2, 2004

how to do this and not found much, so here goes:

I want to generate a variable number of random numbers less than 16 with no duplicate numbers

Ive posted the fla, and what i'm doing is generating a random number and putting it into an array then using a for loop to cycle through the array for each new random number to check if its already there. if it is, then i want to regenerate that number.

if you test the fla you'll see that all i get in my array is some lovely zero's and i sort of know why this is, but don't know how to stop it.

View 6 Replies

ActionScript 3.0 :: Generating Random Number - Pushing Into The Variable And Displaying It To The User

Jan 24, 2012

I am having a really frustrating problem with creating 2 random numbers. When I run the program, everything works fine, until I hit my object and go to the screen "math". Once there, all it shows is one number in one of the 2 boxes. Below is the code used to generate the numbers. I used the "trace" command to see if it was actually generating the numbers, and it is. The problem seems to be with pushing that number into the variable and displaying it to the user.

[Code]....

View 5 Replies

Actionscript :: Selecting The Random Variables?

Feb 16, 2011

Is it possible to randomly select from variables in action script?I have tried using or -

question.text = question1 || question.text = question2;

View 2 Replies

ActionScript 3.0 :: Selecting A Random Frame In Another Scene?

Dec 28, 2011

I have an app I'm creating with Flash CS5.5 with 42 different short stories in it.  It has 2 scenes.  Scene 1 is the opening and contents menu to access the stories.  Scene 2 contains the 42 stories.In scene one, I have a button that I want to be able to pick a random story so it would need to pick a random frame between 1 and 42 in scene 2.  I have seen some code in here that will pick a random frame when you open the program, but I don't know how to tie it to a button or pick a random frame in another scene.

View 14 Replies

ActionScript 2.0 :: Generate A Random Number Between 2 Number BUT Without Generating 2 Same Number?

Jul 16, 2009

Dear Guys I Want To Generate A Random Number Between 2 Number BUT Without Generating 2 Same Number I Mean If For Example Already Generated Number "2" Next Time Did Not Generate It , Is There Any Solution

View 5 Replies

ActionScript 1/2 :: Random MovieClip Script Not Selecting From All Outcomes?

Oct 3, 2009

i have a collection of movie clips (mc0, mc1, mc2...etc etc),and when motion is detected on a webcam, one of these clips is shown on the stage. however, for some reason only mc0, mc1 and mc2 are being displayed, and i cannot get mc3, mc4 or any more to be chosen.

Code:import flash.filters.*// Assumes a Video object named "myVideoObject" is on the Stageactive_cam = Camera.get();filterList = [                 /* 0 */ "multiply",                 /* 1 */ "multiply",                 /* 2 */ "multiply",                /* 3 */ "multiply",                /* 4 */ "multiply"                 ];positionList = [                 /* 0 */ {_x: 512, _y:

[code]....

View 1 Replies

ActionScript 3.0 :: Selecting A Random Movie Clip From Array?

Mar 7, 2010

I know this should be easy, but I can't seem to make it work. All I want is for the variable currentPage to select randomly from an array so that every time the page loads, it displays a different currentPage. This is what I have so far:

var myImages:Array = new Array("outsource_mc","solutions_mc","staff_mc");
var randomImages:Array = [];
var randomCount:Number = 1;
var r:Number;
for (var i = 0; i<randomCount; i++) {

[Code]...

View 6 Replies

ActionScript 2.0 :: Generate A Variable Number Of Random Numbers Less Than 16 With No Duplicate Numbers

Nov 2, 2004

how to do this and not found much, so here goes:

I want to generate a variable number of random numbers less than 16 with no duplicate numbers

Ive posted the fla, and what i'm doing is generating a random number and putting it into an array then using a for loop to cycle through the array for each new random number to check if its already there. if it is, then i want to regenerate that number.

if you test the fla you'll see that all i get in my array is some lovely zero's and i sort of know why this is, but don't know how to stop it.

View 3 Replies

IDE :: Generate Random Number Between 2 Number BUT Without Generating 2 Same Number?

Jul 16, 2009

I Want To Generate A Random Number Between 2 Number BUT Without Generating 2 Same Number I Mean If For Example Already Generated Number "2" Next Time Did Not Generate It,

View 4 Replies

ActionScript 3.0 :: Display A Random Number On The Click Of A Button Without Repeating Any Number In The Array

Sep 9, 2011

I'm trying to create a shuffle button for my mp3 player. I don't want it to repeat any song in the xml playlist until all the songs are played. Is there to display a random number on the click of a button, without repeating any number in the array until all the numbers in the array are used?

View 9 Replies

ActionScript 2.0 :: Function To Create A Random Number And The Char Move Accordingly Depending On The Number?

Aug 9, 2005

my functions in this fla i have. I use the function to create a random number and the char move accordingly depending on the number.

View 4 Replies

ActionScript 3.0 :: Random Number Generator - Make Each Number Unique So It Only Comes Up Once?

Nov 24, 2009

ActionScript Code:
var numbers:Array = [];
var newNb:Number;
var max:Number = 81;

[code]...

View 6 Replies

ActionScript 2.0 :: What Value Is Seeded To Math.random() To Generate The Random Number

Nov 18, 2010

1) what value is seeded to Math.random() to generate the random number?

View 2 Replies

IDE :: Create 100 Unique Random Numbers From Between 0 And 99 Where No Random Number Is Repeated?

Feb 28, 2009

Making a random number between lets say 0 and 99 is relatively straight forward using the Math.random class What is the best way to create 100 unique random numbers from between 0 and 99 where no random number is repeated?Would I make a random number, chuck it into an array then the next random number created is checked against the array, and if the number has been created before try for another number?

View 2 Replies

ActionScript 3.0 :: Make Random Number Between 1 To 10 Without Repeat Number Twice?

Dec 30, 2008

i want to make random number between 1 to 10 without repeat number twice or more i use this function to make random

function getRandomNumber(min:Number, max:Number):Number
{
var randomNumber:Number = Math.round(Math.random() * (max - min) + min);
return randomNumber;
}
getRandomNumber(1, 10);

View 2 Replies

ActionScript 2.0 :: Create A Random Number Without Using Math.random()?

Feb 5, 2010

How can i create a random number without using Math.random() I think this can be done with a array... i just don't know how.

i need it for a google banner. they don't allow Math.random() of random() in the sript

View 2 Replies

ActionScript 2.0 :: Creating An Input Text - A Random Number Will Be Typed In That Text Instead Of Having A Fixed, Pre-set Number?

May 13, 2006

I want to change the code a little bit by creating an Input Text. A random number will be typed in that text instead of having a fixed, pre-set number.

View 6 Replies

Make A Random Number And If Else Get Along?

Oct 22, 2010

I have code that I got off line that will create a random number in the output tab. I put together an if else statement, however I can not figure out what how to call the random number into the if else statement. My last try was calling "n," However that did not work. I have a bit of the code that I am working with. I am giving only the first 3 but there are 13 in total, but as they are all the same just going to different frames I thought that it was not necessary to show them all.

function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNum;

[code]...

If there is an easier way to get the same thing I am open. I just want it to start on a specific random frame (13 of them).

View 21 Replies

ActionScript 3.0 :: Random Number Between 1 & 16?

Nov 1, 2010

I need to create a variable that holds a random number  between 1 & 16. This is the way the variable looks right now:
 
var randomTurkey:Number = Math.floor(Math.random()*100);

View 1 Replies

ActionScript 3.0 :: Random Number Between 0 And 1?

Jan 21, 2010

How do I generate the following random numbers: .1, .2, .3, .4, .5, .6, .7, .8, .9

starting with the code below? I can only get whole numbers between 0 and 9 whole numbers. Is there a way to add the decimal point in front?

ActionScript Code: var randomNumScale:int = Math.floor(Math.random()  * 10)  + 0;

View 4 Replies

ActionScript 2.0 :: Random Number Of The Same Mc?

Jun 6, 2007

I have tried to create 'simple' (!) application where a user enters a 2 digit number in a input text box with instance named 'calc_num', clicks a button named 'cplay_btn' and a random number of the movieclip 'bf_mc' appears on the stage, between 1 and the number in the input box. I have tried numeous ways of writing the script., of which the example below is the most simple:

[Code]...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved