-
XRave
[AS2] Is confused about a path to a MC
So er... I made a MC, and called it 'waterdrop' on the stage. Now I have a MC that's linkage name is 'snow', and within the Waterdrop MC I use attachMovie to add the 'snow' to the scene. Simple.
However, it all messes up around here:
Code is from Control MC within 'waterdrop' MC
Code:
onClipEvent(enterFrame) {
var i2 = _root.getNextHighestDepth();
attachMovie("snow","snow"+i2,i2);
with (_root.waterdrop["snow"+i2]) {
_x = 425+40-80*Math.random();
_y = 90+45-90*Math.random();
_rotation = 60*Math.random();
_xscale = _yscale = 30*Math.random();
_alpha = 100;
}
_root.waterdrop["snow"+i2].onEnterFrame = function() {
with (this) {
_x += _xscale/13;
_y -= _yscale/30;
_alpha -= 2;
if (_x>896 || _y>672 || _alpha<0) {
this.removeMovieClip();
}
}
}
updateAfterEvent();
}
This piece of code works great if it's started by _root.onEnterFrame = function() and use the _root["snow"+i2] path to locate, but if I adapt it to above code, Flash Player tells me that it can't find the specified object for the With(){...}
Can anyone correct this code for me?
Oh, notes:
It basically attaches the clip at a random position near the (425,90), and then let it float sideways on a 1:3 gradient, gradually losing alpha and then getting removed if it drifts out of sight OR if it is transparent.
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
-
XRave
PHP Code:
onClipEvent (load){i3 = _parent.getNextHighestDepth();}
onClipEvent (mouseMove) {
i3 ++
//weird, because trace(i3) actually returns a increasing number.
attachMovie("snow","snow"+i3,i3);
with ("_level"+i3["snow"+i3]) { //working
_x = 0+40-80*Math.random();
_y = 0+45-90*Math.random();
_rotation = 60*Math.random();
_xscale = _yscale=30*Math.random();
_alpha = 100;
}
trace ("_level"+i3["snow"+i3].getDepth()); //output: _levelundefined
this.onEnterFrame = function() { //working
with (this) {
_x += _xscale/13;
_y -= _yscale/30;
_alpha -= 2;
if (_x>896 || _y>672 || _alpha<0) {
this.removeMovieClip();
}
}
};
updateAfterEvent();
}
I made it work by accident, but now the ["snow"+i3] is on _levelundefined according to the trace().
but didn't I attach the clip to the depth i3?
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|