actionscript 3 - Why the Tween Class don't work inside a for with Flash AS3? -


problem


i'm trying make tween many movieclips using command, this:

for(var i:int = 0; < mcarray.length; i++) {      new tween(mcarray[i], "x", regular.easeout, 0, 100, 1.0, true);  } 

but doesn't works. i've tried change code follow down:

var tween:tween = new tween(mcarray[i], "x", regular.easeout, 0, 100, 1.0, true); 

and doesn't works too.

i can't use setinterval or timer because movieclips should synchronized , may cause problems.

is there way this?

as3 tween engine, bad: design, performance etc. if can't use greensock library animation, use gtween, it's great tweening engine under mit licence. without support , continuous improvement, engine much better tween adobe.

working example, after start, if collect every object in center of scene:

package {      import com.gskinner.motion.gtween;     import com.gskinner.motion.easing.sine;      import flash.display.displayobject;     import flash.display.shape;     import flash.display.sprite;     import flash.display.stagealign;     import flash.display.stagescalemode;     import flash.events.event;     import flash.geom.point;      public class stackoverflow extends sprite {          public function stackoverflow() {             addeventlistener(event.added_to_stage, onadded);         }          private function onadded(e:event):void {             removeeventlistener(event.added_to_stage, onadded);              stage.align = stagealign.top_left;             stage.scalemode = stagescalemode.no_scale;              setup();         }          private function createdummyobjects(size:uint):array {             var result:array = [], i:uint, object:shape;             (i; < size; ++i) {                 object = new shape();                 object.graphics.beginfill(math.random() * 0xffffff);                 object.graphics.drawcircle(0, 0, 20);                 result[i] = object;             }             return result;         }          private function setup():void {             var objects:array = createdummyobjects(10);             var i:uint, len:uint = objects.length, item:displayobject, middle:point = new point(stage.stagewidth >> 1, stage.stageheight >> 1);              (i; < len; ++i) {                 item = objects[i];                 item.x = math.random() * stage.stagewidth;                 item.y = math.random() * stage.stageheight;                  addchild(item);                  new gtween(item, 1 + math.random() * 4, {x: middle.x, y: middle.y}, {ease: sine.easeinout});             }         }      } } 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -