View Full Version : Attach to the frame or object
Fishinghat
08-16-2004, 03:07 PM
hi everyone
just started learning flash and i'm trying to duplicate a movie clip that i created, not sure whether my action script is correct:
_root.theCloud = "cloud"+_root.counter;
while (_root.counter<11) {
_root.theCloud.duplicateMovieClip("cloud"+_root.counter, _root.counter);
_root["clouds"+_root.counter]._x = random(550);
_root["clouds"+_root.counter]._y = random(150);
_root.counter++;
trace(_root.myCloud);
trace("counter: "+_root.counter);
}
this ActionScript is attached to a frame
thanks in advance
deQue
08-16-2004, 03:26 PM
I think this: _root.theCloud.duplicateMovieClip("cloud"+_root.counter, _root.counter); should be this: _root.theCloud.duplicateMovieClip(_root.theCloud+_ root.counter, _root.counter);
Fishinghat
08-16-2004, 03:49 PM
it comes out with output:
undefined
counter: 1
undefined
counter: 2
undefined
counter: 3
undefined
counter: 4
undefined
counter: 5
undefined
counter: 6
undefined
counter: 7
undefined
counter: 8
undefined
counter: 9
undefined
counter: 10
undefined
counter: 11
cagemonkey
08-16-2004, 04:05 PM
i'm taking a stab in the dark 'cause i'm at work and can't test it, but try this:
var counter:Number = 1;
while (counter < 11) {
theCloud.duplicateMovieClip("cloud" + counter, counter);
["cloud" + counter]._x = random(550);
["cloud" + counter]._y = random(150);
// It's not very clear what you have this next line for.
// But, it is the cause of your "undefined" values in your output window.
trace(_root.myCloud);
// This line outputs the current value of counter before closing the loop.
trace("counter: " + counter);
counter++;
}
just compare this 2 line and you shut get it
_root["clouds"+_root.counter]._x = random(550);yours
_root["cloud"+_root.counter]._x = random(550); working
OR JUST check :_root.theCloud.duplicateMovieClip("cloud"+_root.counter, _root.counter);
you shud also check : _root.theCloud = "cloud"+_root.counter; it is needed????
whats the name of the original movie to dublicate ? i place a clip whit name theCloud on frame 0 and erease this line :_root.theCloud = "cloud"+_root.counter
get 10 times theCloude on screen (corect "s")
and you need to init _root.counter =0 at least on MX2004
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.