Honestly, I would put all this first on a for loop. Once you finish the for loop, put each element accordingly, then use TweenLite or your favorite Tweening package.
package { import flash.display.Sprite; import flash.events.Event; import gs.TweenLite; import gs.easing.*; public class ExampleDocumentClass extends Sprite { if(stage) _init(); else addEventListener(Event.ADDED_TO_STAGE, _init(), false, 0, true); } private function _init(e:Event =null):void { for(var i:int = 0; i < 25; i++) { var mc:MovieClip = new MovieClip(); mc.graphics.beginFill(Math.random() * 0x000000); mc.graphics.drawRect(0,0,stage.stageWidth,25);
It is important to note that screen updates do NOT occur in code blocks such as for and while loops. You could not place them on the basis of each other as I showed, because although the previous x elements can just be set, it was not displayed on the screen; To create a system in which they say that all images do not have the same width, but need to start after another, we must wait for the Event.COMPLETE event for this loader so that we can access it in width and other attributes. Since you just wanted to place them at a distance of 25 pixels from each other, and they are the same size, we just use โiโ to separate them.
What happens: i * 25 = 0; I ++; i * 25 = 25; I ++; i * 25 = 50;
as you see, we have reached the interval we were looking for.
Brian Hodge
hodgedev.com blog.hodgedev.com
source share