PDA

View Full Version : Global actions for all frames?


Dieuz
11-29-2008, 04:23 PM
Hey,

I have a document with 52 frames w/ 52 different images in them. The thing is that every frames need the same ActionScript code. I dont want to copy/paste in every frames. Is there anyway to apply an ActionScript code to All frames?

Thanks,

Mazoonist
11-29-2008, 04:48 PM
Actionscript code already does apply to all frames. A function defined on a keyframe in frame 1 will still be available on all the subsequent frames. If you need to have something happen that's unique to each of the 52 images (let me guess, playing cards?) then your handler function could be abstracted by using "event.target" or "event.currentTarget." There is almost never a need to copy and paste the same code in multiple places, that's what functions are for. It's just a matter of some brain work to abstract them and make them generic (so they'll work for anything).

Dieuz
11-29-2008, 05:04 PM
Hehe yes it's about playing card! I got a code to drag an image but the code only works if it is in the frame where the image is. If I put the code at frame 1, it's just doesnt seem to work.

I use gotoandstop() to reach the frame where the image is.


image1.addEventListener(MouseEvent.MOUSE_DOWN,move Image);
image1.addEventListener(MouseEvent.MOUSE_UP,dropIm age);

function moveImage(evt:MouseEvent) {
image1.startDrag();
}

function dropImage(evt:MouseEvent) {
image1.stopDrag();
}

How could I modify this to make it Global for every of my images?

Thanks mate!

Mazoonist
11-29-2008, 05:27 PM
It's hard to picture just what you've got, since there are so many different ways to structure this. I'm guessing (from your description) that you've got the 52 card images in a layer on the main timeline. But I could be wrong. You should post your fla file. You have to zip it to upload it here. I'd be glad to check it out.

JimRowan
11-29-2008, 05:37 PM
Make sure you "Insert Frame" in the 52nd frame of your Actions timeline. Otherwise, if you have your keyframe at frame 1 and nothing after that, the Actions timeline won't go past frame 1.

Plain old Insert Frame - not keyframe.