all groups > flash actionscript > january 2007 >
You're in the

flash actionscript

group:

creating a function in a movie clip.


creating a function in a movie clip. DZ-015
1/29/2007 11:14:33 PM
flash actionscript:
OK - so i have this method (which is in a class, if that matters) that receives
a MovieClip. I want the method to create a function inside this movie clip and
link it to the onEnterFrame even of the movie clip.

What kind of syntax can i use for this? I'm familiar with creating and
deleting events, but not familiar with creating functions dynamically.

Thanks for your help!
Re: creating a function in a movie clip. coldMiner
1/30/2007 2:25:40 AM
Something like this?

var mcl:MovieClip;
var mcLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
listener.onLoadInit = function(target:MovieClip):Void {
target.onEnterFrame = function(){
// your code
};
};
mcLoader.addListener(listener);
mcLoader.loadClip("example.swf", mcl);
Re: creating a function in a movie clip. SymTsb
1/30/2007 2:44:00 AM
I would imagine you are trying to do something similar to what I am doing.

I would add the onEnterFrame to your class constructor... look at my code
below...

// I'm assuming something similar to this in your class
container_mc = createEmptyMovieClip("myClip", depth);

container_mc.onEnterFrame = doSomething();

public function doSomething() {
// Whatever code you like here....
}
AddThis Social Bookmark Button