Re: [Flashcoders] changing a MovieClip instance class at runtime inAS2 ?
workz !!! thx RA + eka :) On 11/26/06, eka [EMAIL PROTECTED] wrote: Hello :) Don't forget to use the inherit in your class :) class classes.TestClass extends MovieClip { /** * Constructor */ public function TestClass() { trace( constructor : TestClass); } public function action() { trace(some action); } } PS : use uppercase to begin the name of your classes... MovieClip, LoadVars, TextField etc... all this classes begin with a uppercase character. PS2 : use a reference property in your main class import classes.TestClass ; /** * The Main class of the application. */ class Application { /** * Constructor, creates a new Main instance. */ function Application( target:MovieClip ) { // register the reference of you view in the class (it's a shortcut !) myMC = target.testMC ; // Change inherit myMC.__proto__ = TestClass.prototype ; TestClass.call( myMC ) ; // Use TestClass method myMC.action(); } /** * The reference of my view. */ public var myMC:MovieClip ; /** * Main method (use this method in mtasc ?) */ static public function main( target:MovieClip ) { var main:Main = new Main(target) ; } } PS3 : you can try to use my ConstructorUtil class in VEGAS my openSource framework : http://vegas.riaforge.org/ 1 - Download the framework 2 - install my AS2 library in Flash or MTASC with the AS2/trunk/src class path. 3 - You can find my ConstructorUtil AS2 tool class in the package vegas.util.* : http://vegas.riaforge.org/index.cfm?event=page.svnbrowsepath=%2FAS2%2Ftrunk%2Fsrc%2Fvegas/util In this class you can use the methods : createVisualInstance(class:Function, oVisual, oInit) You can try to use too my vegas.util.factory.DisplayFactory class ... Try the examples in AS2/trunk/bin/test/util/... directory EKA+ :) 2006/11/24, Dani Bacon [EMAIL PROTECTED]: hey eka. thx it seems to almost do the trick it changes the class prototype but errors when i try to initialize the constructor using the call method. on stage i have a MC called testMC and the code im using- class Main { static function main() { _root.testMC.__proto__ = classes.testClass.prototype ; classes.testClass.call(_root.testMC); _root.testMC.action(); } } class classes.testClass { public function testClass() { trace(test); } public function action() { trace(some action); } } errors with - type error classes.testClass have no static field call commenting put the .call() line compiles and prints some action any ideas how i can get the constructor to be called? thanks for all your help :) On 11/23/06, eka [EMAIL PROTECTED] wrote: Hello :) You must use the __proto__ reference to change the inherit of yours movieclips :) example 1 : you create an empty movieclip and you want attach a new class who extends MovieClip ! import myPackage.MyClass ; var mc = createEmptyMovieClip(mc, 1) ; mc.__proto__ = MyClass.prototype ; // i change the default __proto__ reference(MovieClip.prototype) with the prototype of MyClass. MyClass.call(mc) ; // if you want launch the constructor of the class and initialize the movieclip example 2 : your movieclip is allready on the stage, it's the same operation :) mc.__proto__ = MyClass.prototype ; // i change the default __proto__ reference(MovieClip.prototype) with the prototype of MyClass. MyClass.call(mc) ; // if you want launch the constructor of the class and initialize the movieclip You can create a function to lauch this hack ... it's more easy. eKA+ :) 2006/11/23, Dani Bacon [EMAIL PROTECTED]: hi marijan yeah thats exactly it, im using exactly that - inject code, to attach my classes to assets in a SWF file. but what happens is that any MC in that SWF that is linked to a class via the symbols properties panel, is ignored. ive used registerClass in Main to correct that, which does but not for instances that are already on stage. so im looking for another way to attach a class to a MovieClip instance in runtime ? thx .. dani On 11/22/06, Marijan Miličević [EMAIL PROTECTED] wrote: as far as I know, FD ignores anything on the stage unless you choose inject code compile method, see compiler options within FD, hth -m -Original Message- From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] On Behalf Of Dani Bacon Sent: Wednesday, November 22, 2006 5:50 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] changing a MovieClip instance class at runtime inAS2 ? hey TMK. thank you for your interest :) i started working with FlashDevelop + mtasc and would like to compile my projects solely via FlashDevelop. this way i would
Re: [Flashcoders] changing a MovieClip instance class at runtime inAS2 ?
Hello :) Don't forget to use the inherit in your class :) class classes.TestClass extends MovieClip { /** * Constructor */ public function TestClass() { trace( constructor : TestClass); } public function action() { trace(some action); } } PS : use uppercase to begin the name of your classes... MovieClip, LoadVars, TextField etc... all this classes begin with a uppercase character. PS2 : use a reference property in your main class import classes.TestClass ; /** * The Main class of the application. */ class Application { /** * Constructor, creates a new Main instance. */ function Application( target:MovieClip ) { // register the reference of you view in the class (it's a shortcut !) myMC = target.testMC ; // Change inherit myMC.__proto__ = TestClass.prototype ; TestClass.call( myMC ) ; // Use TestClass method myMC.action(); } /** * The reference of my view. */ public var myMC:MovieClip ; /** * Main method (use this method in mtasc ?) */ static public function main( target:MovieClip ) { var main:Main = new Main(target) ; } } PS3 : you can try to use my ConstructorUtil class in VEGAS my openSource framework : http://vegas.riaforge.org/ 1 - Download the framework 2 - install my AS2 library in Flash or MTASC with the AS2/trunk/src class path. 3 - You can find my ConstructorUtil AS2 tool class in the package vegas.util.* : http://vegas.riaforge.org/index.cfm?event=page.svnbrowsepath=%2FAS2%2Ftrunk%2Fsrc%2Fvegas/util In this class you can use the methods : createVisualInstance(class:Function, oVisual, oInit) You can try to use too my vegas.util.factory.DisplayFactory class ... Try the examples in AS2/trunk/bin/test/util/... directory EKA+ :) 2006/11/24, Dani Bacon [EMAIL PROTECTED]: hey eka. thx it seems to almost do the trick it changes the class prototype but errors when i try to initialize the constructor using the call method. on stage i have a MC called testMC and the code im using- class Main { static function main() { _root.testMC.__proto__ = classes.testClass.prototype ; classes.testClass.call(_root.testMC); _root.testMC.action(); } } class classes.testClass { public function testClass() { trace(test); } public function action() { trace(some action); } } errors with - type error classes.testClass have no static field call commenting put the .call() line compiles and prints some action any ideas how i can get the constructor to be called? thanks for all your help :) On 11/23/06, eka [EMAIL PROTECTED] wrote: Hello :) You must use the __proto__ reference to change the inherit of yours movieclips :) example 1 : you create an empty movieclip and you want attach a new class who extends MovieClip ! import myPackage.MyClass ; var mc = createEmptyMovieClip(mc, 1) ; mc.__proto__ = MyClass.prototype ; // i change the default __proto__ reference(MovieClip.prototype) with the prototype of MyClass. MyClass.call(mc) ; // if you want launch the constructor of the class and initialize the movieclip example 2 : your movieclip is allready on the stage, it's the same operation :) mc.__proto__ = MyClass.prototype ; // i change the default __proto__ reference(MovieClip.prototype) with the prototype of MyClass. MyClass.call(mc) ; // if you want launch the constructor of the class and initialize the movieclip You can create a function to lauch this hack ... it's more easy. eKA+ :) 2006/11/23, Dani Bacon [EMAIL PROTECTED]: hi marijan yeah thats exactly it, im using exactly that - inject code, to attach my classes to assets in a SWF file. but what happens is that any MC in that SWF that is linked to a class via the symbols properties panel, is ignored. ive used registerClass in Main to correct that, which does but not for instances that are already on stage. so im looking for another way to attach a class to a MovieClip instance in runtime ? thx .. dani On 11/22/06, Marijan Miličević [EMAIL PROTECTED] wrote: as far as I know, FD ignores anything on the stage unless you choose inject code compile method, see compiler options within FD, hth -m -Original Message- From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] On Behalf Of Dani Bacon Sent: Wednesday, November 22, 2006 5:50 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] changing a MovieClip instance class at runtime inAS2 ? hey TMK. thank you for your interest :) i started working with FlashDevelop + mtasc and would like to compile my projects solely via FlashDevelop. this way i would have the design team i work with set up the symbols and stage with all the visual assets needed, and set up linkageIDs to them. then i would be able to set up those symbols functionality via
Re: [Flashcoders] changing a MovieClip instance class at runtime inAS2 ?
anyone ? i need to figure out how to run a classes constructor after it was dynamically linked to a MovieClip on stage ? On 11/24/06, Dani Bacon [EMAIL PROTECTED] wrote: hey eka. thx it seems to almost do the trick it changes the class prototype but errors when i try to initialize the constructor using the call method. on stage i have a MC called testMC and the code im using- class Main { static function main() { _root.testMC.__proto__ = classes.testClass.prototype ; classes.testClass.call(_root.testMC); _root.testMC.action(); } } class classes.testClass { public function testClass() { trace(test); } public function action() { trace(some action); } } errors with - type error classes.testClass have no static field call commenting put the .call() line compiles and prints some action any ideas how i can get the constructor to be called? thanks for all your help :) On 11/23/06, eka [EMAIL PROTECTED] wrote: Hello :) You must use the __proto__ reference to change the inherit of yours movieclips :) example 1 : you create an empty movieclip and you want attach a new class who extends MovieClip ! import myPackage.MyClass ; var mc = createEmptyMovieClip(mc, 1) ; mc.__proto__ = MyClass.prototype ; // i change the default __proto__ reference(MovieClip.prototype) with the prototype of MyClass. MyClass.call (mc) ; // if you want launch the constructor of the class and initialize the movieclip example 2 : your movieclip is allready on the stage, it's the same operation :) mc.__proto__ = MyClass.prototype ; // i change the default __proto__ reference(MovieClip.prototype) with the prototype of MyClass. MyClass.call(mc) ; // if you want launch the constructor of the class and initialize the movieclip You can create a function to lauch this hack ... it's more easy. eKA+ :) 2006/11/23, Dani Bacon [EMAIL PROTECTED]: hi marijan yeah thats exactly it, im using exactly that - inject code, to attach my classes to assets in a SWF file. but what happens is that any MC in that SWF that is linked to a class via the symbols properties panel, is ignored. ive used registerClass in Main to correct that, which does but not for instances that are already on stage. so im looking for another way to attach a class to a MovieClip instance in runtime ? thx .. dani On 11/22/06, Marijan Miličević [EMAIL PROTECTED] wrote: as far as I know, FD ignores anything on the stage unless you choose inject code compile method, see compiler options within FD, hth -m -Original Message- From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] On Behalf Of Dani Bacon Sent: Wednesday, November 22, 2006 5:50 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] changing a MovieClip instance class at runtime inAS2 ? hey TMK. thank you for your interest :) i started working with FlashDevelop + mtasc and would like to compile my projects solely via FlashDevelop. this way i would have the design team i work with set up the symbols and stage with all the visual assets needed, and set up linkageIDs to them. then i would be able to set up those symbols functionality via external code. i wouldnt mind linking classes to MCs using the symbols properties panel, but FlashDevelop ignores those links. so using registerClass in Main i can link linkageIDs to classes but that only works for dynamic attachments of MC instances. any ideas ? [snip..] ___ 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
Re: [Flashcoders] changing a MovieClip instance class at runtime inAS2 ?
hey eka. thx it seems to almost do the trick it changes the class prototype but errors when i try to initialize the constructor using the call method. on stage i have a MC called testMC and the code im using- class Main { static function main() { _root.testMC.__proto__ = classes.testClass.prototype ; classes.testClass.call(_root.testMC); _root.testMC.action(); } } class classes.testClass { public function testClass() { trace(test); } public function action() { trace(some action); } } errors with - type error classes.testClass have no static field call commenting put the .call() line compiles and prints some action any ideas how i can get the constructor to be called? thanks for all your help :) On 11/23/06, eka [EMAIL PROTECTED] wrote: Hello :) You must use the __proto__ reference to change the inherit of yours movieclips :) example 1 : you create an empty movieclip and you want attach a new class who extends MovieClip ! import myPackage.MyClass ; var mc = createEmptyMovieClip(mc, 1) ; mc.__proto__ = MyClass.prototype ; // i change the default __proto__ reference(MovieClip.prototype) with the prototype of MyClass. MyClass.call(mc) ; // if you want launch the constructor of the class and initialize the movieclip example 2 : your movieclip is allready on the stage, it's the same operation :) mc.__proto__ = MyClass.prototype ; // i change the default __proto__ reference(MovieClip.prototype) with the prototype of MyClass. MyClass.call(mc) ; // if you want launch the constructor of the class and initialize the movieclip You can create a function to lauch this hack ... it's more easy. eKA+ :) 2006/11/23, Dani Bacon [EMAIL PROTECTED]: hi marijan yeah thats exactly it, im using exactly that - inject code, to attach my classes to assets in a SWF file. but what happens is that any MC in that SWF that is linked to a class via the symbols properties panel, is ignored. ive used registerClass in Main to correct that, which does but not for instances that are already on stage. so im looking for another way to attach a class to a MovieClip instance in runtime ? thx .. dani On 11/22/06, Marijan Miličević [EMAIL PROTECTED] wrote: as far as I know, FD ignores anything on the stage unless you choose inject code compile method, see compiler options within FD, hth -m -Original Message- From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] On Behalf Of Dani Bacon Sent: Wednesday, November 22, 2006 5:50 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] changing a MovieClip instance class at runtime inAS2 ? hey TMK. thank you for your interest :) i started working with FlashDevelop + mtasc and would like to compile my projects solely via FlashDevelop. this way i would have the design team i work with set up the symbols and stage with all the visual assets needed, and set up linkageIDs to them. then i would be able to set up those symbols functionality via external code. i wouldnt mind linking classes to MCs using the symbols properties panel, but FlashDevelop ignores those links. so using registerClass in Main i can link linkageIDs to classes but that only works for dynamic attachments of MC instances. any ideas ? [snip..] ___ 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] changing a MovieClip instance class at runtime inAS2 ?
Hello :) You must use the __proto__ reference to change the inherit of yours movieclips :) example 1 : you create an empty movieclip and you want attach a new class who extends MovieClip ! import myPackage.MyClass ; var mc = createEmptyMovieClip(mc, 1) ; mc.__proto__ = MyClass.prototype ; // i change the default __proto__ reference(MovieClip.prototype) with the prototype of MyClass. MyClass.call(mc) ; // if you want launch the constructor of the class and initialize the movieclip example 2 : your movieclip is allready on the stage, it's the same operation :) mc.__proto__ = MyClass.prototype ; // i change the default __proto__ reference(MovieClip.prototype) with the prototype of MyClass. MyClass.call(mc) ; // if you want launch the constructor of the class and initialize the movieclip You can create a function to lauch this hack ... it's more easy. eKA+ :) 2006/11/23, Dani Bacon [EMAIL PROTECTED]: hi marijan yeah thats exactly it, im using exactly that - inject code, to attach my classes to assets in a SWF file. but what happens is that any MC in that SWF that is linked to a class via the symbols properties panel, is ignored. ive used registerClass in Main to correct that, which does but not for instances that are already on stage. so im looking for another way to attach a class to a MovieClip instance in runtime ? thx .. dani On 11/22/06, Marijan Miličević [EMAIL PROTECTED] wrote: as far as I know, FD ignores anything on the stage unless you choose inject code compile method, see compiler options within FD, hth -m -Original Message- From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] On Behalf Of Dani Bacon Sent: Wednesday, November 22, 2006 5:50 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] changing a MovieClip instance class at runtime inAS2 ? hey TMK. thank you for your interest :) i started working with FlashDevelop + mtasc and would like to compile my projects solely via FlashDevelop. this way i would have the design team i work with set up the symbols and stage with all the visual assets needed, and set up linkageIDs to them. then i would be able to set up those symbols functionality via external code. i wouldnt mind linking classes to MCs using the symbols properties panel, but FlashDevelop ignores those links. so using registerClass in Main i can link linkageIDs to classes but that only works for dynamic attachments of MC instances. any ideas ? [snip..] ___ 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] changing a MovieClip instance class at runtime inAS2 ?
as far as I know, FD ignores anything on the stage unless you choose inject code compile method, see compiler options within FD, hth -m -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dani Bacon Sent: Wednesday, November 22, 2006 5:50 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] changing a MovieClip instance class at runtime inAS2 ? hey TMK. thank you for your interest :) i started working with FlashDevelop + mtasc and would like to compile my projects solely via FlashDevelop. this way i would have the design team i work with set up the symbols and stage with all the visual assets needed, and set up linkageIDs to them. then i would be able to set up those symbols functionality via external code. i wouldnt mind linking classes to MCs using the symbols properties panel, but FlashDevelop ignores those links. so using registerClass in Main i can link linkageIDs to classes but that only works for dynamic attachments of MC instances. any ideas ? [snip..] ___ 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