View Full Version : storing paths in variables
Ricod
11-03-2001, 11:18 AM
I have very long paths (_root.MC1.MC2.MC3.MC4.etc)
I'd like to store them in variables in the _root with :
_root:PathEtc = _root.MC1.MC2.MC3.MC4.etc;
Then shouldn't I be able to use _root.PathEtc whenever I normally would've used _root.MC1.MC2.MC3.MC4.etc, right ?
or should I place _root.MC1.MC2.MC3.MC4.etc between " " ?
I tried all sorts of stuff, but sometimes it works, and sometimes it won't. Main reason would be filesize, cpu and RAM. I know it helps for html pages, but does it also help for Flash ? (even if its only 1 bit per character )
Also, can I mask dynamicaly loaded text ? Or does that only work with static text ? (m'be I'm just maskin wrong ...) Any way, I know it doesn't work with input textboxes ... but why not the dynamic ones ... it's still text right ?
Jesse
11-03-2001, 10:14 PM
_root.longPath = "my.Really.Long.Path.Note.No.Root.Reference";
// then I can use it as a path, see the advance pathing tutorial:
_root[longPath].myVar = value;
Ricod
11-16-2001, 03:32 PM
I know I'm a little late, but this doesn't work.
I've tried :
_root[longPath]._visible = false;
_root[_root.longPath]._visible = false;
_root[_root:longPath]._visible = false;
_root[longPath+"._visible"] = false;
_root[_root.longPath+"._visible"] = false;
_root[_root:longPath+"._visible"] = false;
and none of m worked ... I've read the advanced paths tutorial, studied it and restudied it, but no go.
It has to be the code, cuz if I write out the longPath it works fine.
PLZ help ! I've been at this problem for 3 days now ... I've put 2 threads on the forum and nothing comes out of it ...
I've tried the dynamic pathing on a variable, and there it DOES work. For that I have :
_root:Message = "_root.MenuBar.MessageScreen.MessageBox:Message";
and call that with :
_root[_root:Message] = "some text here ";
and its displayed correctly. Does it just work on variables ? I thought u could store the paths to anything (like MC's)
Jesse
11-17-2001, 04:31 AM
OK it works like this: _root.path = "parent.child.grandchild";
_root[eval(path)]._visible = false;
obviously we have to eval coz it's more than one level of pathing...
Ricod
11-19-2001, 08:11 AM
Thanks ! the eval works perfect ! (just had to include the actions inside the [] brackets too !)
stv_cg
01-10-2005, 09:56 PM
OK it works like this: _root.path = "parent.child.grandchild";
_root[eval(path)]._visible = false;
obviously we have to eval coz it's more than one level of pathing...
I have a question about this thread.
What if I have a instance like this...
_root.path1 = "parent.child1.grandchild";
_root.path2 = "parent.child2.grandchild";
Would I write that out like this?
_root[eval(path)+1]._visible = false;
_root[eval(path)+2]._visible = false;
Or is it possible to have something like this?
_root.path1 = "parent.child[InsertVariable].grandchild";
_root.path2 = "parent.child[InsertVariable].grandchild";
stv_cg
01-10-2005, 10:03 PM
I tried this...
test.onPress = function() {
_root.path = "symbol.square1.fill";
_root[eval(path)]._alpha=50
}
But it changes everting to 50% not the fill clip :confused:
JohnF
01-11-2005, 09:34 AM
I use an object to deal with long or changing paths.
var bePath:Object = new Object();
bePath = _root.application.Tools.breakeven.breakevencalc;
for (i=0; i<ohArray.length; i++) {
bePath[ohArray[i]+"Label"].setStyle("textAlign", "right");
}
stv_cg:
you would write it as this:
_root[eval(path1)]._visible = false;
_root[eval(path2)]._visible = false;
stv_cg
01-13-2005, 11:11 PM
Thanks for the help!! It totally helped me figure a bunch of things out.
Here is how I ended up doing it....
v1 = 2
v2 = 2
v3 = 2
Iname1 = "mc"
Iname2 = "sl"
Iname3 = "in"
path1 = Iname1 + v1
path2 = Iname2 + v2
path3 = Iname3 + v3
_root.attachMovie(Iname1,path1,0);
_root[path1].attachMovie(Iname2,path2,0);
_root[path1][path2].attachMovie(Iname3,path3,0);
So if any one is having problems inserting 2 or multiple variables into a path that attaches a movie this worked in MX 7.2. Here is what the path I want to dynamically build looks like if I were to hard code it...
variable1.variable2.attachMovie("linkname","instancename",0)
so if you want "variable1" & "variable2" to be variables then the formatting goes like this...
_root[variable1][variable2].attachMovie("linkname","instancename",0)
the brackets automatical
Here is my test fla file....
http://www.stvcg.com/port/03-exp/attachMovie_In_A_Movie.zip
Thanks again for the Help! :)
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.