This is a project I have been working on lately and I keep running into problems.
The idea is to be able to attaching an animation to a movie clip and call it later. Or multiple animation at once.
example:
on the stage you have a black box called: myClip
in actionscript you type:
growClip = grow(myClip);
spinClip = spin(myClip);
now when you call:
growClip.run();
spinClip.run();
myClip will grow and spin.
These function are ran with setinterval but when I do this myClip only spins.
the function grow looks like this:
The idea for the above code is from Adobe Spry framework
Does setInterval cancel if they are applied together?
The idea is to be able to attaching an animation to a movie clip and call it later. Or multiple animation at once.
example:
on the stage you have a black box called: myClip
in actionscript you type:
growClip = grow(myClip);
spinClip = spin(myClip);
now when you call:
growClip.run();
spinClip.run();
myClip will grow and spin.
These function are ran with setinterval but when I do this myClip only spins.
the function grow looks like this:
Code:
grow = function(mc,opts){ //opts == object containing required vars opts.dir = (opts.dir > 0 || opts.dir == 0)?1:-1; id=random(10000); mc["attach_animation"+id] = {} co = mc["attach_animation"+id]; co.grow = {} //Start: effect creation co.grow.run = function(){ mc._xscale = mc._yscale = (opts.dir > 0)?0:100; co.grow.growID = setInterval(co.grow.effect,5); }; co.grow.kill = function(){ if(mc._xscale < 1) mc._visible = false; mc._xscale = mc._yscale = 100; clearInterval(co.grow.growID); delete co.grow; trace("motion complete"); }; co.grow.effect = function(){ mc._xscale += opts.dir; mc._yscale = mc._xscale; if(mc._xscale < 1 || mc._xscale > 100){ co.grow.kill(); } }; co.grow.growID = 0; //END: effect creation return co.grow; } growthis = grow(myClip,{dir:1}); shrinkthis = grow(myClip,{dir:-1}); growthis.run();
Does setInterval cancel if they are applied together?
Comment