Re: [Flashcoders] Load/export Symbol in ActionScript
I couldn't remember - but having had a trawl it seems it was Peter Hall (see http://www.peterjoel.com/blog) - but I've been unable to find the original article. Basically as each class is loaded it gets assigned a symbol name __Packages.class path. Ian On 11/30/05, de-hack SWF [EMAIL PROTECTED] wrote: On 11/30/05, Ian Thomas [EMAIL PROTECTED] wrote: Hi Juguang, Try replacing the line: public static var symbolName:String=RMC; with: public static var symbolName:String=__Packages.RMC; HTH, YTH! (Yes, that helps) My week-lasting exhaust is breezed away. Many thanks. :-) By the way, where did you get this naming convention? Juguang. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Load/export Symbol in ActionScript
Creating a fake named linkage'd run-time symbol is done another way. But I don't remember it by hearth. Maybe someone else can feed on this one. Yes. Thanks. You identify my problem. This is the point that I want to know. Anyone any ideas? :-) Juguang ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Load/export Symbol in ActionScript
Hi Juguang, I posted the following about a week ago - I think it's what you're after: -- Can't remember where I got this solution - definitely not mine - but here's how to create a MovieClip-derived class that doesn't need an associated library symbol: -- class net.something.MyButton extends MovieClip { static var symbolName:String = __Packages.net.something.MyButton ; static var symbolOwner:Function = MyButton; public function MyButton() { } static var symbolLinked=Object.registerClass(symbolName, symbolOwner); } -- To create it, use attachMovie: import net.something.MyButton; var button:MyButton=MyButton(myTimeline.attachMovie(MyButton.symbolName, someRandomButton, myTimeline.getNextHighestDepth())); Where myTimeline is whatever parent movie clip you're trying to attach to. HTH, Ian (I think I'll go away and put this in the FAQ...) On 11/29/05, de-hack SWF [EMAIL PROTECTED] wrote: Creating a fake named linkage'd run-time symbol is done another way. But I don't remember it by hearth. Maybe someone else can feed on this one. Yes. Thanks. You identify my problem. This is the point that I want to know. Anyone any ideas? :-) Juguang ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Load/export Symbol in ActionScript
Hi Ian, thanks! But I have read such code many times and in many forum. However, my this piece of stupid code just does now work for me. (But it runs well, if I manually add a symbol 'RMC', in Flash) Can someone test on your side and tell me if it is working in your environment? Big thanks!! - Juguang // RMC.as class RMC extends MovieClip { public function RMC(){} public function init(w, h){ this.lineStyle(2, 0xff, 100); this.moveTo(0, 0); this.lineTo(100, 100); } public static var symbolName:String=RMC; public static var symbolOwner:Function=RMC; public static var symbolLinked=Object.registerClass(symbolName, symbolOwner); } // entry import RMC; var mc = _root.attachMovie(RMC.symbolName, myname, _root.getNextHighestDepth()); trace(mc); var rmc=RMC(mc); rmc.init(100, 100); /// the end On 11/29/05, Ian Thomas [EMAIL PROTECTED] wrote: Hi Juguang, I posted the following about a week ago - I think it's what you're after: -- Can't remember where I got this solution - definitely not mine - but here's how to create a MovieClip-derived class that doesn't need an associated library symbol: -- class net.something.MyButton extends MovieClip { static var symbolName:String = __Packages.net.something.MyButton ; static var symbolOwner:Function = MyButton; public function MyButton() { } static var symbolLinked=Object.registerClass(symbolName, symbolOwner); } -- To create it, use attachMovie: import net.something.MyButton; var button:MyButton=MyButton(myTimeline.attachMovie(MyButton.symbolName, someRandomButton, myTimeline.getNextHighestDepth())); Where myTimeline is whatever parent movie clip you're trying to attach to. HTH, Ian (I think I'll go away and put this in the FAQ...) On 11/29/05, de-hack SWF [EMAIL PROTECTED] wrote: Creating a fake named linkage'd run-time symbol is done another way. But I don't remember it by hearth. Maybe someone else can feed on this one. Yes. Thanks. You identify my problem. This is the point that I want to know. Anyone any ideas? :-) Juguang ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Programmable Flash, empowered by open-source projects, the future of web presentation and interaction. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Load/export Symbol in ActionScript
Hi Juguang, Try replacing the line: public static var symbolName:String=RMC; with: public static var symbolName:String=__Packages.RMC; HTH, Ian On 11/29/05, de-hack SWF [EMAIL PROTECTED] wrote: Hi Ian, thanks! But I have read such code many times and in many forum. However, my this piece of stupid code just does now work for me. (But it runs well, if I manually add a symbol 'RMC', in Flash) Can someone test on your side and tell me if it is working in your environment? Big thanks!! - Juguang ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Load/export Symbol in ActionScript
On 11/30/05, Ian Thomas [EMAIL PROTECTED] wrote: Hi Juguang, Try replacing the line: public static var symbolName:String=RMC; with: public static var symbolName:String=__Packages.RMC; HTH, YTH! (Yes, that helps) My week-lasting exhaust is breezed away. Many thanks. :-) By the way, where did you get this naming convention? Juguang. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Load/export Symbol in ActionScript
Normally, you would keep the RMCSymbol in your library with the linkage and class association and not use Object.registerClass. If you want to associated your symbol dynamically to a class at run-time you can use Objec.registerClass(RMCSymbol, RMC); for example. This function can only set your class association It doesn't create a fake symbol in your run-time library for Flash to instantiate when you do attachMovie(RMCSymbol, ...). Creating a fake named linkage'd run-time symbol is done another way. But I don't remember it by hearth. Maybe someone else can feed on this one. Basically, Object.registerClass associates a class (RMC) to a linkage'd symbol (RMCSymbol) that must exist. Hope that helps! Fredz./ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of de-hack SWF Sent: November 29, 2005 1:01 AM To: Flashcoders mailing list Subject: [Flashcoders] Load/export Symbol in ActionScript Dear all, I am new to flash programming, so my question may be silly. In the first frame of new flash document, I have the code like this. trace(hello); var rmc = _root.attachMovie(RMCSymbol, rmc_1, 2); trace(rmc); RMC(rmc).init(100, 200); Where RMC is a subclass of MovieClip. I created an empty RMCSymbol symbol make the linkage between RMCSymbol and RMC class in Symbol Properties dialog, and the swf works. Now, I delete RMCSymbol and try to add the registration code like var tmp:RMC; Object.registerClass(RMCSymbol, RMC); before the previous code. It does not work as what I had previously and trace(rmc) prints undefined. Did I miss something here? Many thanks! Juguang ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders