Action on a list of objects
Hi there
I was used to play with Flash several years ago and today i'm trying to create some funny staff in order to learn AS3 and Animate basics.
I have a "truck" movie clip on my scene. This movie clip has a stop(); action on the first frame and a gotoAndPlay(2); on the last frame of its timeline.
When the global timeline plays i wrote this code in order to get the truck bigger and to get it play if the truck's x is greater than 300.
I have 3 questions:
1 - is it possible to simplify my code specify x > 300 and < 900
2 - is it possible to scale x and y in the same time (rather than scaleX and scaleY)
3 - I would like to apply this code to several other movie clips, is there a way to for example list my objects and then apply my code to all this objects
addEventListener(Event.ENTER_FRAME, transform_objects);
function transform_objects(event:Event):void
{
truck.x += 5;
if(truck.x >= 1400){
truck.x = -150;
}
if(truck.x >= 300){
truck.play();
truck.scaleX = 1.4;
truck.scaleY = 1.4;
truck.alpha = 1;
}
if(truck.x >= 900){
truck.gotoAndStop(1);
truck.scaleX = 1;
truck.scaleY = 1;
truck.alpha = 0.16;
}
}
Thank you very much for your help
Regards
Miran
