Skip to main content
May 29, 2006
Question

Check for movie clips with AS?

  • May 29, 2006
  • 5 replies
  • 450 views
Is it possible to check if a frame contain a movie clip with AS, and then if movie clip is found run a function? Like a global "event handler " for movie clips.
This topic has been closed for replies.

5 replies

Participating Frequently
May 30, 2006
Ehhm. you need to place this code in the first frame of your movie - just to be sure
Participating Frequently
May 30, 2006
So basically you want to create a function that is called each time any movieclip appears anywhere in the FlashMovie ?

That could be easy done with prototypes. I have not tested it but i am pretty sure that will work:

MovieClip.prototype.init = function() {

trace("Yo ! i am your new movieclip. My instance name is "+_name);
// do whatever you want to do within that movieclip here. Remember that you are already INSIDE of the movieclip

};
MovieClip.prototype.onLoad = function() {

init();

};

kglad
Community Expert
Community Expert
May 29, 2006
if you're not fading every movieclip instantiated on a particular frame how will you decide which movieclips need to be faded?
kglad
Community Expert
Community Expert
May 29, 2006
will it fade every movieclip found?
May 29, 2006
Nope, that was my question if it was possible to do somethin like that
kglad
Community Expert
Community Expert
May 29, 2006
yes, though i'm not sure what you need to do. but i'm fairly certain it can be done.

do you want to define a function that returns all the movieclips instantiated on a particular keyframe?
May 29, 2006
I want a function that automaticly can detect and fade in any movie clip found in any keyframe in the main timeline. So i don't have to make

In the first keyframe in the main timeline

on (ohh here i found a movie clip)
{
//let's run a nice fade function on that movie clip

mx.transitions.TransitionManager.start
(eval(TheClip),
{type:mx.transitions.Fade,
direction:0,
duration:1,
easing:mx.transitions.easing.None.easeNone,
param1:empty,
param2:empty
});

}

Something like that