Groups | Blog | Home
all groups > flash actionscript > june 2004 >

flash actionscript : send variable to movieclip


MaureenM
6/21/2004 7:25:42 PM
How would I send a variable from the main timeline into a particular nested
movie clip if the movie clip is targetted using a variable?

I'm trying variations of:
set(_root.alllogos.logoclip[_level0.randomnumber].CompanyID,
_level0.companyid);

I know that my _level0.randomnumber and _level0.companyid variables work
(using trace)- it's more the targetting that's the problem. I then want to be
able to access the companyid variable from within the logoclip0, logoclip1,
logoclip2 etc. movieclips using simply this.companyid.

Any ideas?
Thanks,
Maureen


Jack.
6/21/2004 7:59:43 PM
try -
MaureenM
6/21/2004 8:47:50 PM
Hi Jack,
Great - that seems to work on the main timeline... so I have:

_level0.alllogos["logoclip"+_level0.randomnumber].CompanyID =
_level0.companyid;
trace("companyid on logoclip 2 = " + _level0.alllogos.logoclip2.companyid);

and the trace brings back the correct value for logoclip2... but... I still
can't access it on my logoclip though...
On my logoclip2 for example I'm using two traces:
trace("this.companyid = " + this.companyid);
trace("companyid on logoclip 2 = " + _level0.alllogos.logoclip2.companyid);
Both turn up empty.
What am I missing?
Jack.
6/21/2004 9:28:08 PM
i cannot get it to fail :))
i placed a textfield on stage, var name - CompanyID
converted it to movieclip, so i now have
logoclip2.CompanyID
converted to movieclip again, so i now have
alllogos.logoclip2.CompanyID

inside of logoclip2, i add the trace
trace("this.companyid = " + this.companyid);

i come back to the main timeline and add
_level0.randomnumber = 2;
_level0.companyid = "two";
_level0.alllogos["logoclip"+_level0.randomnumber].CompanyID =
_level0.companyid;
trace("companyid on logoclip 2 = " + _level0.alllogos.logoclip2.companyid);

the output is -
companyid on logoclip 2 = two
this.companyid = two

does any of this help ?
MaureenM
6/22/2004 3:27:29 PM
I think I've figured it out.
I also have a LoadMovie that loads a jpg into the logoclip2 movieclip. I find
when I comment out the LoadMovie line it works. Does that mean that when I do a
LoadMovie it wipes out any variables in that movieclip? In any case I've done a
work around - setting a number of new variables on the main timeline.
Maureen
Jack.
6/22/2004 4:35:02 PM
Hi Maureen - for reference, the loadMovie action will
overwrite all coding on the target clip, a workaround
is to use onEnterFrame to loop and poll the _width
property of the target clip, when it is no longer zero,
apply your code and delete the onEnterFrame loop.

hth
AddThis Social Bookmark Button