View Full Version : attachMovie in MX
friz2002
12-20-2002, 09:32 PM
Hi,
I have an mc outside the stage with the following code
onClipEvent(load){
for(i=0;i<10;i++){
_root.attachMovie("mc","mc"+i,i);
_root["mc"+i]._x = i*35+50;
}
}
onClipEvent(enterFrame){
for(i=0;i<10;i+=2){
_root["mc"+i]._rotation +=5;
_root["mc"+(i+1)]._rotation -=5;
}
}
How would I do this the 'MX-way" with all the script on the main timeline and without the mc outside the stage?
say the mc you have all this code on is named 'rotator'
then your code would look something like:
rotator.onLoad=function(){
for(i=0;i<10;i++){
rm=_root.attachMovie("mc","mc"+i,i);
rm._x = i*35+50;
}
};
rotator.onEnterFrame=function(){
for(i=0;i<10;i+=2){
_root["mc"+i]._rotation +=5;
_root["mc"+(i+1)]._rotation -=5;
}
};
the modification i made in your load event is not really necissary, i just thought i would show ya a diffent way to write it.
anyway... this should all work, play around with it.
friz2002
12-20-2002, 11:12 PM
Thx for the answer.
I think I wasn't very clear in my 1st post.
In the ex. I have given, the code is on a movieclip outside the stage.
The "mc" in the code is the identifier (linkage) from a movieclip in my library (not on stage)
I attached the fla to this message.
What I want is, that when the swf is loaded, the movieclip is taken from the library, placed on stage(export in first frame)and then all the rotation stuff happens, but in a MX way with all my code on the first frame of the main timeline and nothing on the stage.
Maybe something like object.registerClass ???
I tried your code.
I put an mc (instance name rotator ) on stage and a mc in my library (linkage identifier mc)
and nothing happend?
BTW, how would i change the code so the wheels fit in each other?
I tried _root["raderke"+(i+1)]._rotation +=15; in the onLoad but that didn't work.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.