Wednesday, May 9, 2012

[Action Script] Clearing MovieClip in a for Loop May,2012

I'm trying something complex, but the troublesome part of my code (within a movieclip on the stage) can be simplified to this:
Code: onClipEvent(load){
        w1=10;
        w2=20;
        w3=30;
}

onClipEvent(enterFrame){
for(n=0;n<13;n++){
var m1:MovieClip =
_root.createEmptyMovieClip("my_mc"+[n], random(100));
m1.lineStyle(2,0xFF000F,100);
m1.beginFill(0x0000FF,10);
m1.moveTo(w1*n,10*n);
m1.lineTo(w2*n,50);
m1.lineTo(w3*n,n*n);
m1.lineTo(w1*n,10*n);
}
m1.clear();
}

on(keyPress "<Left>"){w1-=1;}
on(keyPress "<Right>"){w1+=1;}Unfortunately, the m1.clear() doesn't actually clear the m1 movieclips. When you press left and right, the old ones stay where they are, until random depth conflicts make them vanish after a while.
Every position I've tried for the m1.clear() either does nothing at all, or clears them before they've even been drawn and nothing appears on stage.
Is there anyway to get rid of them? I want them to be constantly being drawn, cleared, and redrawn. The alpha should stay, then, at 10, and they should move smoothly instead of leaving old ones behind.

Thankyou to anyone with any ideas!
Clearing MovieClip in a for Loop

Related Post



0 comments: