View Full Version : adding data to a movieclip
spacetoon
09-20-2005, 10:07 AM
i think the code explains my problem, also, i want to add new field to the movie clip, this is the first, second, i want to change the alpha factor of the movie clip which extended from another movie clip
CMC.onPress=function()
{
trace(s);//not working
}
function printPressedObjectName(st:String)
{
trace(st);
}
CMC.createEmptyMovieClip("mc1",1);
CMC.createEmptyMovieClip("mc2",3);
CMC.mc1.s=new String("mclip1");
CMC.mc2.s=new String("mclip2");
trace(CMC.mc1.s);//done correctly
CMC.mc1.loadMovie("C:\\a.swf");
CMC.mc2.loadMovie("C:\\b.swf");
CMC.mc1._alpha=100;//also not working
CMC.mc2._alpha=100;//not working
CMC.onPress=function()
{
trace(s);//not working
}
CMC.mc1._x=100;
CMC.mc1._y=100;
CMC.mc2._x=200;
CMC.mc2._y=200;
finchou
09-20-2005, 10:38 AM
CMC.onPress=function()
{
trace(s);//traces undefined, which is the value of s in this scope
}
CMC.mc1._alpha=100;//has no effect, 100 means "no transparency"
CMC.mc2._alpha=100;//
correct me if I misunderstood something...
spacetoon
09-20-2005, 11:43 AM
thanks,
first, according to the fact of s is added to the movie clip, so when the onPress is activated, CMC and the childs can recognize s, when s is already added to mc1, mc2
so, if this won't work , how can i add a value to the movie clip, and by calling onPress of CMC, i can get the value of it through the childs,
second,
changing alpha is not working anyway, although if i changed the value from 100 to 50 as example,
appreciate your response,
can i get any elp
thanks
finchou
09-20-2005, 11:58 AM
trace(CMC.mc1.s);//different from
trace(CMC.mc2.s);
for your other problem I don't know, what happens if you set the alpha before loading the clip?
spacetoon
09-20-2005, 12:10 PM
actually, even this didn't work, the output is undefined
CMC.createEmptyMovieClip("mc1",1);
CMC.createEmptyMovieClip("mc2",3);
CMC.mc1.loadMovie("C:\\a.swf");
CMC.mc2.loadMovie("C:\\b.swf");
CMC.mc1.s=new String("mc1");
CMC.mc2.s=new String("mc2");
CMC.onPress=function()
{
trace(CMC.mc1.s);//not working
}
??????
finchou
09-20-2005, 12:13 PM
what about
{
trace(this.mc1.s);
}
?
CyanBlue
09-20-2005, 12:15 PM
Whatever you have defined goes down the drain once you initiate the loadMovie() on that movieClip... Hence 's' will be nothing by the time when you try to trace it...
If you really have to define 's' in that movieClip, do define it AFTER the content is fully loaded... ;)
spacetoon
09-20-2005, 12:22 PM
actually
{
trace(this.mc1.s);
}
didn't work
thanks CyanBlue for your reply.
but how does that work. i mean achieving the loading then entering the data.
actually i think it's something about inheritance problem, cause mc1 is considered as a child for CMC, or thats not right.??
please check http://www.actionscript.org/forums/showthread.php3?t=84331
it shows the whole problem
thanks
Spacetoon :confused:
finchou
09-20-2005, 12:28 PM
you have to use a onLoad() function and inside that function initilialize your values...
spacetoon
09-20-2005, 12:53 PM
but on which instance i have to define the onLoad,
more the onLoad won't work all the time, cause i want to change the values through run time of the swf
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.