I load an image and add it to the MC someMC. If “something” is true, the someVariable gets the someMC scaleX number. Let’s say its 0.82.
What I need is to get that number into the s.value in my Slider object. Since I want the Slider value to be where my image scale is.
This of course doesn’t work because of variable scope limitations.
I have tried setting the variable at the top of the code like this:
var someVariable:Number;
but that didn’t work either.
Here’s the code:
function completeHandler(event:Event):void{
if (something) {
var someVariable:Number = this.someMC.scaleX;
}
}
var s:Slider = new Slider();
s.maximum = 500;
s.minimum = 10;
s.value = someVariable;
Any thoughts?
Update
I’m looking for a solution without having to use package and class, since I’m not that steady with AS3 yet.
Update 2
I’ve uploaded all the code to Pastebin. Take a look 😉
The
thisin your completeHandler is not the document. Try just someMC.scaleX, and assuming you declared it on your main timeline or wherever, it should have access to it. The scaleX property also only ranges from 0 to 1, so if your Slider is from 10:500 — that’s not going to work. I put * 100 in there for you, but do whatever math is required to fix the scale to what you were intending.Also, you need to explicitly set the Slider’s value in the handler, rather then just changing the var. Variables aren’t passed like that in AS3.