[Flashcoders] Attach sub class to swf which is loaded via attachMovie()?
Just curious if it is possible to extend/apply a sub class to a swf which is loaded via attachMovie()? TIA, Cheers, M -- Wishlist: http://snipurl.com/vrs9 Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Attach sub class to swf which is loaded via attachMovie()?
function Square(){} Square.prototype=new MovieClip(); Square.prototype.changeColorTo=function (clr:Number) { var tempClr:Color=new Color(this); tempClr.setRGB(clr); delete tempClr; } var linkageID_str:String=exportedClip; //associate the linked clip with sub class Object.registerClass(linkageID_str,Square); //attach var mc:MovieClip= attachMovie(linkageID_str,mc,1); //then prohibit further association of linked clip to class Object.registerClass(linkageID_str,null); //when you call the method it should work mc.changeColorTo(0xFF); Same idea if you're working with Actionscript 2.0 Y Shouman On 12/1/06, Micky Hulse [EMAIL PROTECTED] wrote: Just curious if it is possible to extend/apply a sub class to a swf which is loaded via attachMovie()? TIA, Cheers, M -- Wishlist: http://snipurl.com/vrs9 Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Attach sub class to swf which is loaded via attachMovie()?
Excellent! Many many many thanks Yehia and EKA... I have not had any luck finding examples on the www... both examples will be great for me to learn from. :D Thanks again! Cheers, Micky -- Wishlist: http://snipurl.com/vrs9 Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Attach sub class to swf which is loaded via attachMovie()?
You're welcome Micky EKA, I've been really confused by the garbage collection and how it sometimes sits their coldly not doing the job ! I read somewhere the garbage collection won't fire unless the application is in a still state. In an application, that I had some interval process happening, the garbage collection never worked and the memory usage kept going up. I've watched a presentation by G Skinner, read some articles, but never found a way to fire that garbage collector other than minimizing the application (and that works in IE, it doesnt with firefox). So its an act of anxiety ! Can you point us to links where the garbage collection work ?, Perhaps with a new message Thanks for your comment, Yehia On 12/1/06, eka [EMAIL PROTECTED] wrote: Hello :) the __proto__ solution is a good solution : /** * Constructor of the class */ function Square() { this.draw() ; } /** * Square extends MovieClip */ Square.prototype.__proto__ = MovieClip.prototype ; /** * Draw the square shape. */ Square.prototype.draw = function() { this.beginFill(0xFF, 100) ; this.lineTo(100,0) ; this.lineTo(100,100) ; this.lineTo(0,0) ; this.lineTo(0,0) ; this.endFill() ; } /** * Sets the color of the movieclip. */ Square.prototype.setRGB = function ( color:Number ) { (new Color(this)).setRGB(color) ; } // test attachMovie var mc1:MovieClip = attachMovie(myID, myClip, 1) ; mc1.__proto__ = Square.prototype ; // change the prototype reference Square.call(mc2) ; // launch the constructor of the Square class mc1.setRGB(0xFF) ; // ok // test with createEmptyMovieClip var mc2:MovieClip = createEmptyMovieClip(myClip2, 2) ; mc2.__proto__ = Square.prototype ; // change the prototype reference Square.call(mc2) ; // launch the constructor of the Square class mc2.setRGB(0xFF) ; // ok @Yehia Shouman : your delete in your changeColorTo method is useless because all local variables with a var in a method is remove by the Garbage collector at the end of the call function. EKA+ :) 2006/12/1, Yehia Shouman [EMAIL PROTECTED]: function Square(){} Square.prototype=new MovieClip(); Square.prototype.changeColorTo=function (clr:Number) { var tempClr:Color=new Color(this); tempClr.setRGB(clr); delete tempClr; } var linkageID_str:String=exportedClip; //associate the linked clip with sub class Object.registerClass(linkageID_str,Square); //attach var mc:MovieClip= attachMovie(linkageID_str,mc,1); //then prohibit further association of linked clip to class Object.registerClass(linkageID_str,null); //when you call the method it should work mc.changeColorTo(0xFF); Same idea if you're working with Actionscript 2.0 Y Shouman On 12/1/06, Micky Hulse [EMAIL PROTECTED] wrote: Just curious if it is possible to extend/apply a sub class to a swf which is loaded via attachMovie()? TIA, Cheers, M -- Wishlist: http://snipurl.com/vrs9 Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Attach sub class to swf which is loaded via attachMovie()?
Hello :) a delete in a function failed to destroy a variable ;) My french article about this subject : http://www.ekameleon.net/blog/index.php?2006/06/10/34--as-ssas-delete-un-peu-capricieux Used google translator or bablefish if you want read my article in english (sorry .. i speak english very bad...) delete method returns false if the variable isn't clear on memory (protected with a ASSetPropFlags or if the variable is undefined too) function test() { var a = 1 ; trace( a : + a) ; // a : 1 trace(i remove the variable 'a' : + delete(a)) ; // output false trace( a : + a) ; // a : 1 // the value isn't deleted ! } trace(++ delete sur une variable dans une fonction) ; test() ; .. you can read some good articles about Garbage collector (in FP8 and FP9 the garbage is better...) - http://www.tekool.net/flash/benchmark/garbage_collector/ (french) - http://weblog.shaoken.be/index.php?2005/09/23/17-gestion-du-garbage-collector-sous-flash8(french) - http://www.blog.lessrain.com/?p=237 (benchmark) - http://www.kaourantin.net/2005/09/garbage-collection-in-flash-player-8.html(english) - http://www.adobe.com/devnet/flashplayer/articles/fp8_performance.html(english) - http://www.informit.com/guides/content.asp?g=flashseqNum=344rl=1(english) - http://www.gskinner.com/blog/archives/2006/09/garbage_collect.html (search the key work Garbage collector in this blog) EKA+ :) 2006/12/1, Yehia Shouman [EMAIL PROTECTED]: You're welcome Micky EKA, I've been really confused by the garbage collection and how it sometimes sits their coldly not doing the job ! I read somewhere the garbage collection won't fire unless the application is in a still state. In an application, that I had some interval process happening, the garbage collection never worked and the memory usage kept going up. I've watched a presentation by G Skinner, read some articles, but never found a way to fire that garbage collector other than minimizing the application (and that works in IE, it doesnt with firefox). So its an act of anxiety ! Can you point us to links where the garbage collection work ?, Perhaps with a new message Thanks for your comment, Yehia On 12/1/06, eka [EMAIL PROTECTED] wrote: Hello :) the __proto__ solution is a good solution : /** * Constructor of the class */ function Square() { this.draw() ; } /** * Square extends MovieClip */ Square.prototype.__proto__ = MovieClip.prototype ; /** * Draw the square shape. */ Square.prototype.draw = function() { this.beginFill(0xFF, 100) ; this.lineTo(100,0) ; this.lineTo(100,100) ; this.lineTo(0,0) ; this.lineTo(0,0) ; this.endFill() ; } /** * Sets the color of the movieclip. */ Square.prototype.setRGB = function ( color:Number ) { (new Color(this)).setRGB(color) ; } // test attachMovie var mc1:MovieClip = attachMovie(myID, myClip, 1) ; mc1.__proto__ = Square.prototype ; // change the prototype reference Square.call(mc2) ; // launch the constructor of the Square class mc1.setRGB(0xFF) ; // ok // test with createEmptyMovieClip var mc2:MovieClip = createEmptyMovieClip(myClip2, 2) ; mc2.__proto__ = Square.prototype ; // change the prototype reference Square.call(mc2) ; // launch the constructor of the Square class mc2.setRGB(0xFF) ; // ok @Yehia Shouman : your delete in your changeColorTo method is useless because all local variables with a var in a method is remove by the Garbage collector at the end of the call function. EKA+ :) 2006/12/1, Yehia Shouman [EMAIL PROTECTED]: function Square(){} Square.prototype=new MovieClip(); Square.prototype.changeColorTo=function (clr:Number) { var tempClr:Color=new Color(this); tempClr.setRGB(clr); delete tempClr; } var linkageID_str:String=exportedClip; //associate the linked clip with sub class Object.registerClass(linkageID_str,Square); //attach var mc:MovieClip= attachMovie(linkageID_str,mc,1); //then prohibit further association of linked clip to class Object.registerClass(linkageID_str,null); //when you call the method it should work mc.changeColorTo(0xFF); Same idea if you're working with Actionscript 2.0 Y Shouman On 12/1/06, Micky Hulse [EMAIL PROTECTED] wrote: Just curious if it is possible to extend/apply a sub class to a swf which is loaded via attachMovie()? TIA, Cheers, M -- Wishlist: http://snipurl.com/vrs9 Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Attach sub class to swf which is loaded via attachMovie()?
No don't worry man about your english. Thanks alot eka, Yehia On 12/1/06, eka [EMAIL PROTECTED] wrote: Hello :) a delete in a function failed to destroy a variable ;) My french article about this subject : http://www.ekameleon.net/blog/index.php?2006/06/10/34--as-ssas-delete-un-peu-capricieux Used google translator or bablefish if you want read my article in english (sorry .. i speak english very bad...) delete method returns false if the variable isn't clear on memory (protected with a ASSetPropFlags or if the variable is undefined too) function test() { var a = 1 ; trace( a : + a) ; // a : 1 trace(i remove the variable 'a' : + delete(a)) ; // output false trace( a : + a) ; // a : 1 // the value isn't deleted ! } trace(++ delete sur une variable dans une fonction) ; test() ; .. you can read some good articles about Garbage collector (in FP8 and FP9 the garbage is better...) - http://www.tekool.net/flash/benchmark/garbage_collector/ (french) - http://weblog.shaoken.be/index.php?2005/09/23/17-gestion-du-garbage-collector-sous-flash8(french) - http://www.blog.lessrain.com/?p=237 (benchmark) - http://www.kaourantin.net/2005/09/garbage-collection-in-flash-player-8.html(english) - http://www.adobe.com/devnet/flashplayer/articles/fp8_performance.html(english) - http://www.informit.com/guides/content.asp?g=flashseqNum=344rl=1(english) - http://www.gskinner.com/blog/archives/2006/09/garbage_collect.html(search the key work Garbage collector in this blog) EKA+ :) 2006/12/1, Yehia Shouman [EMAIL PROTECTED]: You're welcome Micky EKA, I've been really confused by the garbage collection and how it sometimes sits their coldly not doing the job ! I read somewhere the garbage collection won't fire unless the application is in a still state. In an application, that I had some interval process happening, the garbage collection never worked and the memory usage kept going up. I've watched a presentation by G Skinner, read some articles, but never found a way to fire that garbage collector other than minimizing the application (and that works in IE, it doesnt with firefox). So its an act of anxiety ! Can you point us to links where the garbage collection work ?, Perhaps with a new message Thanks for your comment, Yehia On 12/1/06, eka [EMAIL PROTECTED] wrote: Hello :) the __proto__ solution is a good solution : /** * Constructor of the class */ function Square() { this.draw() ; } /** * Square extends MovieClip */ Square.prototype.__proto__ = MovieClip.prototype ; /** * Draw the square shape. */ Square.prototype.draw = function() { this.beginFill(0xFF, 100) ; this.lineTo(100,0) ; this.lineTo(100,100) ; this.lineTo(0,0) ; this.lineTo(0,0) ; this.endFill() ; } /** * Sets the color of the movieclip. */ Square.prototype.setRGB = function ( color:Number ) { (new Color(this)).setRGB(color) ; } // test attachMovie var mc1:MovieClip = attachMovie(myID, myClip, 1) ; mc1.__proto__ = Square.prototype ; // change the prototype reference Square.call(mc2) ; // launch the constructor of the Square class mc1.setRGB(0xFF) ; // ok // test with createEmptyMovieClip var mc2:MovieClip = createEmptyMovieClip(myClip2, 2) ; mc2.__proto__ = Square.prototype ; // change the prototype reference Square.call(mc2) ; // launch the constructor of the Square class mc2.setRGB(0xFF) ; // ok @Yehia Shouman : your delete in your changeColorTo method is useless because all local variables with a var in a method is remove by the Garbage collector at the end of the call function. EKA+ :) 2006/12/1, Yehia Shouman [EMAIL PROTECTED]: function Square(){} Square.prototype=new MovieClip(); Square.prototype.changeColorTo=function (clr:Number) { var tempClr:Color=new Color(this); tempClr.setRGB(clr); delete tempClr; } var linkageID_str:String=exportedClip; //associate the linked clip with sub class Object.registerClass(linkageID_str,Square); //attach var mc:MovieClip= attachMovie(linkageID_str,mc,1); //then prohibit further association of linked clip to class Object.registerClass(linkageID_str,null); //when you call the method it should work mc.changeColorTo(0xFF); Same idea if you're working with Actionscript 2.0 Y Shouman On 12/1/06, Micky Hulse [EMAIL PROTECTED] wrote: Just curious if it is possible to extend/apply a sub class to a swf which is loaded via attachMovie()? TIA, Cheers, M -- Wishlist: http://snipurl.com/vrs9 Switch: http://browsehappy.com/ BCC?: http://snipurl.com/w6f8 My: http://del.icio.us/mhulse ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: