In a class definition, where I want to dynamicaly create a MovieClip, I encounter 2 problems : 1) When I set the "_visible" property to false, it does not desappear ! 2) When I redefine the onRelease Clip handler, it doesn't send the message to the newly created Clip. I'm using Actionscript 2.0 indeed, and the _visible property seems not to function as intended... And my next problem is to redefine the event handlers of my newly created Clip from inside the class which created it in it"s constructor. Here is my code : class MyClass { private var myClip:MovieClip; public function MyClass (target:MovieClip, myDepth:Number) { createMyMovieClip (target, myDepth); } }
Sorry for the preceding post. It was late and I didn't paste the real code. It doesn't respond to my intention to detect the "mouseDown" on my newly created clip. Here it is : class MyClass { private var myMovie:MovieClip; private var theTarget:MovieClip; // // public function MyClass(theTarget:MovieClip, prof:Number) { createClip(theTarget, prof); } // private function createClip(theTarget:MovieClip, prof:Number):Void { myMovie = theTarget.createEmptyMovieClip("nomClip", prof); myMovie._x = 10; myMovie._y = 10; myMovie.loadMovie("cr.gif"); trace("onRelease on my clip"); // myMovie.onMouseDown = function() { trace("onRelease on my clip"); this._visible = false; }; } }
Timing issue. When loading stuff, you have to wait untill the stuff you want to load is fully loaded before you define props/handlers. Easiest solution is using the MovieClipLoader Class and define props/handlers in the onLoadInit handler. In the class definition: private var loader:MovieClipLoader; In the constructor: loader=new MovieClipLoader(); loader.addListener(this); A class member to handle the onLoadInit event: private function onLoadInit(target_mc:MovieClip):Void{ target_mc.onRelease=function():Void{ this._visible=false; }; } And use the MovieClipLoader instance to load loader.loadClip("myPicture.gif",myClip);
:cool; Thanks a lot. I'm going to try that stuff immedately. I didn't think about this kind of timed issue before going to the OOP in FLASH. Great discoveries on my programming horizon. Thank you for the help.
Don't see what you're looking for? Try a search.
|