Re: [Flashcoders] Strong typing vs attachMovie
Of course :) thanks guys, totally escaped my mind - A Johannes Nel wrote: you cast var UIClock:Clock = Clock (content.attachMovie("clock","uiclock1",1)); the cleanest way is prob to put a static create function on the class itself IMO. from the fdt template public static function create(container : MovieClip,name : String, depth : Number, init : Object) : Clock{ var mc : MovieClip = container.attachMovie("linkage", name, depth, init); return Clock(mc); } On 8/14/06, Andreas Rønning <[EMAIL PROTECTED]> wrote: So say i have a movieClip in my library associated with the class Clock. In my application i want an instance of Clock on stage, so i do something like this: var UIClock:Clock = content.attachMovie("clock","uiclock1",1); naturally i'll get compiler errors, since attachMovie returns a MovieClip. Is there a way to circumvent this? I really enjoy associating library clips with classes and attaching them; aside from this issue i've had no problems. - A ___ 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 -- - Andreas Rønning --- Flash guy Rayon Visual Concepts, Oslo, Norway --- ___ 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] Strong typing vs attachMovie
Hi Andreas, var UIClock:Clock = Clock(content.attachMovie("clock","uiclock1",1)); using className(supertype) i.e. Clock(supertype) It's called typecasting - or just casting. It looks like a constructor function but isn't. Basically you're telling the compiler "It's okay I know what I'm doing - it really is a Clock!" (This assumes you've associated Clock with the "clock" symbol via the Linkage dialog.) HTH, Ian On 8/14/06, Andreas Rønning <[EMAIL PROTECTED]> wrote: So say i have a movieClip in my library associated with the class Clock. In my application i want an instance of Clock on stage, so i do something like this: var UIClock:Clock = content.attachMovie("clock","uiclock1",1); naturally i'll get compiler errors, since attachMovie returns a MovieClip. Is there a way to circumvent this? I really enjoy associating library clips with classes and attaching them; aside from this issue i've had no problems. - A ___ 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] Strong typing vs attachMovie
you cast var UIClock:Clock = Clock (content.attachMovie("clock","uiclock1",1)); the cleanest way is prob to put a static create function on the class itself IMO. from the fdt template public static function create(container : MovieClip,name : String, depth : Number, init : Object) : Clock{ var mc : MovieClip = container.attachMovie("linkage", name, depth, init); return Clock(mc); } On 8/14/06, Andreas Rønning <[EMAIL PROTECTED]> wrote: So say i have a movieClip in my library associated with the class Clock. In my application i want an instance of Clock on stage, so i do something like this: var UIClock:Clock = content.attachMovie("clock","uiclock1",1); naturally i'll get compiler errors, since attachMovie returns a MovieClip. Is there a way to circumvent this? I really enjoy associating library clips with classes and attaching them; aside from this issue i've had no problems. - A ___ 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 -- j:pn http://www.lennel.org ___ 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] Strong typing vs attachMovie
Hello :) You can use *typecasting* : var UIClock:Clock = Clock(content.attachMovie("clock","uiclock1",1)) ; EKA+ :) EKA+ :) 2006/8/14, Andreas Rønning <[EMAIL PROTECTED]>: So say i have a movieClip in my library associated with the class Clock. In my application i want an instance of Clock on stage, so i do something like this: var UIClock:Clock = content.attachMovie("clock","uiclock1",1); naturally i'll get compiler errors, since attachMovie returns a MovieClip. Is there a way to circumvent this? I really enjoy associating library clips with classes and attaching them; aside from this issue i've had no problems. - A ___ 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] Strong typing vs attachMovie
So say i have a movieClip in my library associated with the class Clock. In my application i want an instance of Clock on stage, so i do something like this: var UIClock:Clock = content.attachMovie("clock","uiclock1",1); naturally i'll get compiler errors, since attachMovie returns a MovieClip. Is there a way to circumvent this? I really enjoy associating library clips with classes and attaching them; aside from this issue i've had no problems. - A ___ 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