7 Replies Latest reply on Aug 2, 2006 11:05 AM by kglad

# Flash Movie Clip Variables

NOTE: This code is in a Movie Clip..

What I am trying to do is use FlashVars. I have HTML like this:

<param name="flashvars" value="high=62&low=2">

I want highNumber to be = to the value high from above and if its not there highNumber to be =to 40, and the same thing for lowNumber. I attached what I have so far. I know the variable is going into flash because I made a textbox the regular animation, and the values came up.... so

• ###### 1. Re: Flash Movie Clip Variables
is the problem that high and low are strings?
• ###### 2. Re: Flash Movie Clip Variables
Hi,

sound like a path problem. Every variable passed to a swf is accesible via the _root and as you said your code is in a movieclip; so i suggest this:

if(high == undefined){
var highNumber = 40;
} else {
var highNumber = _root.high;
}
if(low == undefined){
var lowNumber = 1;
} else {
var lowNumber = _root.low;
}
• ###### 3. Re: Flash Movie Clip Variables
Thanks. I am using the attached code now. And this is what happens.... If I don't set any variables in FLASHVARS then it does 0-9 and then if I set high=9&low=0 it outputs numbers 0-9 but with a zero on the end.... anybody know how to fix this?
• ###### 4. Re: Flash Movie Clip Variables
Its doing that weird thing to every number if I put in high = 40 and low =1 then i get numbers in the hundreds... is my line:

number.text = Math.round(Math.random() * (highNumber - lowNumber)) + lowNumber;

right when it comes to making a random number between high and low?
• ###### 5. Re: Flash Movie Clip Variables
convert your strings to numbers. you can use the flash Number() function.
• ###### 6. Re: Flash Movie Clip Variables
Thanks!
• ###### 7. Re: Flash Movie Clip Variables
you're welcome.