-
Let's say I have the name of an instance called 'themovie1' dumped into a vriable called 'select'.
If I had a button at the top that would change the scale of any movieclip on the stage according the name of the variable, how would I reference it?
I have tried a few methods, but they don't work..
_root._name.select._yscale
and
_root.select._yscale
Please help! I know this is probably very simple.. just like me.
-
eval("_root." add select add "._yscale")
-
Originally posted by frames
eval("_root." add select add "._yscale")
Thanks! That sounds a little closer to what I'm looking for. But I guess I should have shown the whole formula for what I'm trying to do, because I still can't get it to scale the instances properly. Should I have those '+1' and '= 150' arguments on the inside or the outside of the brackets?
onClipEvent (enterFrame) {
if (drag == true) {
eval("_root." add select add "._yscale") = eval("_root." add select add "._yscale")+1;
eval("_root." add select add "._xscale") = eval("_root." add select add "._xscale")+1;
}
if (eval("_root." add select add "._yscale") > 150) {
eval("_root." add select add "._yscale") = 150;
eval("_root." add select add "._xscale") = 150;
}
}
onClipEvent (load) {
}
-
or
_root[select]._yscale;
martin.
-
to clean it up a bit, use a couple more variables to refer to the x and yscale properties.
onClipEvent (enterFrame) {
// get the current values
var xs = _root[select]._yscale;
var ys = _root[select]._xscale;
// same as if drag == true
if (drag) {
// same as ys = ys + 1;
ys++;
xs++;
}
if (ys > 150) {
ys = 150;
xs = 150;
}
// update the clip using the modified values
_root[select]._yscale = ys;
_root[select]._xscale = xs;
}
The advantage of putting the values into the variables is that if / when you start adding more code to check and modify the scale, you can modify the variables first, check they are in range, and then put them back into the properties.
I hope this makes sense.
martin.
-
I've noticed something else now.. while looking at the debug boxes, I saw this:
Movie Clip: Frame=2 Target="_level0.themovie1"
Variable _level0.select = "themovie1"
I tried accessing them again using what you guys gave me, but replacing _root with _level0
It still doesn't work!
-
I had the same issue as you and someone offered this, and it works well:
animal=pig;
_root.animal.gotoAndPlay(2);
that will gotoAndPlay frame 2 of movieclip _root.pig...
This is 100% correct, the problem lies somewhere else.
-
Forgive me if I'm a tad obvious (i'm trying to learn this stuff too!)
I believe the reason why using:
eval("_root." add select add "._yscale")
isn't working for ya is that select is *not* a string, perhaps?
if select was a string you would have to assign it like so:
select= "movieclip1";
I am unsure which way you need to assign it to refer to the clips. I know that the way I mentioned before will work, but then it gets tricky to play around & modify the names of the clips, etc.
hope this helps
chris
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|