Re: [Flashcoders] as3 Loader.content.name error
If you want to call addChild on the content then you can simply do: addChild(event.target.content) and that will throw your content on the stage. I'm not sure why it is not possible to name that new content. I've tried playing around with this myself and can't figure out how once you've loaded the content you can access that content as a class. I've loaded up swfs and can reference classes within the swf no problem and create instances of those classes but if I try to get a class definition for the content all I can get is MovieClip and I can't figure out how to create new instances of the that loaded content without running another loader Not sure if that helps you any or not. Rob On Wed, 06 Jun 2007 22:59:33 -0400, Patrick Matte|BLITZ [EMAIL PROTECTED] wrote: Is there a way a change the name of the Loader content property. I'd like to call addChild() on the content instead of the Loader itself. Like this : loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.INIT, loaderInit); var request:URLRequest = new URLRequest(pageSource); loader.load(request); private function loaderInit(event:Event):void{ event.target.removeEventListener(Event.INIT, loaderInit); var page:Page = event.target.content; page.name = test; } That code throws this error but I cant understand why. Error: Error #2078: The name property of a Timeline-placed object cannot be modified. at flash.display::DisplayObject/set name() at com.blitzagency.fabric::Main/::loaderInit() ___ 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] as3 Loader.content.name error
I want to rename the content because I need to be able to access it later using getChildByName(test); But since its not possible, I think I'll have to make my classes dynamic and do this instead : private function loaderInit(event:Event):void{ event.target.removeEventListener(Event.INIT, loaderInit); this[test] = event.target.content; addChild( this[test] ); } BLITZ | Patrick Matte - 310-551-0200 x214 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rob Romanek Sent: Thursday, June 07, 2007 7:19 AM To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] as3 Loader.content.name error If you want to call addChild on the content then you can simply do: addChild(event.target.content) and that will throw your content on the stage. I'm not sure why it is not possible to name that new content. I've tried playing around with this myself and can't figure out how once you've loaded the content you can access that content as a class. I've loaded up swfs and can reference classes within the swf no problem and create instances of those classes but if I try to get a class definition for the content all I can get is MovieClip and I can't figure out how to create new instances of the that loaded content without running another loader Not sure if that helps you any or not. Rob On Wed, 06 Jun 2007 22:59:33 -0400, Patrick Matte|BLITZ [EMAIL PROTECTED] wrote: Is there a way a change the name of the Loader content property. I'd like to call addChild() on the content instead of the Loader itself. Like this : loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.INIT, loaderInit); var request:URLRequest = new URLRequest(pageSource); loader.load(request); private function loaderInit(event:Event):void{ event.target.removeEventListener(Event.INIT, loaderInit); var page:Page = event.target.content; page.name = test; } That code throws this error but I cant understand why. Error: Error #2078: The name property of a Timeline-placed object cannot be modified. at flash.display::DisplayObject/set name() at com.blitzagency.fabric::Main/::loaderInit() ___ 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] as3 Loader.content.name error
Couldn't you just set a variable and pass that to whichever class/method needs to access the child by name? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Patrick Matte|BLITZ Sent: Thursday, June 07, 2007 1:40 PM To: flashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] as3 Loader.content.name error I want to rename the content because I need to be able to access it later using getChildByName(test); But since its not possible, I think I'll have to make my classes dynamic and do this instead : private function loaderInit(event:Event):void{ event.target.removeEventListener(Event.INIT, loaderInit); this[test] = event.target.content; addChild( this[test] ); } BLITZ | Patrick Matte - 310-551-0200 x214 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rob Romanek Sent: Thursday, June 07, 2007 7:19 AM To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] as3 Loader.content.name error If you want to call addChild on the content then you can simply do: addChild(event.target.content) and that will throw your content on the stage. I'm not sure why it is not possible to name that new content. I've tried playing around with this myself and can't figure out how once you've loaded the content you can access that content as a class. I've loaded up swfs and can reference classes within the swf no problem and create instances of those classes but if I try to get a class definition for the content all I can get is MovieClip and I can't figure out how to create new instances of the that loaded content without running another loader Not sure if that helps you any or not. Rob On Wed, 06 Jun 2007 22:59:33 -0400, Patrick Matte|BLITZ [EMAIL PROTECTED] wrote: Is there a way a change the name of the Loader content property. I'd like to call addChild() on the content instead of the Loader itself. Like this : loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.INIT, loaderInit); var request:URLRequest = new URLRequest(pageSource); loader.load(request); private function loaderInit(event:Event):void{ event.target.removeEventListener(Event.INIT, loaderInit); var page:Page = event.target.content; page.name = test; } That code throws this error but I cant understand why. Error: Error #2078: The name property of a Timeline-placed object cannot be modified. at flash.display::DisplayObject/set name() at com.blitzagency.fabric::Main/::loaderInit() ___ 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] as3 Loader.content.name error
Another workaround that I've been using is to use the loading swf as wrapper for the movieClip I ultimately want to display on the stage. Create the content you want to use as movieClip symbol in your swf, export for actionscript, no need to put it on the stage, and give it a class name. Now you can load the wrapper swf. As soon as you do all the classes in that wrapper will be available throughout your project and you can access them by name. Untested e-mail code: loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.INIT, loaderInit); var request:URLRequest = new URLRequest(pageSource); loader.load(request); private function loaderInit(event:Event):void{ var myClass:Class = getDefinitionByName(myClassInMySwf) as Class; var newClip:MovieClip = new myClass(); newClip.name = test; addChild(newClip); } This way you can create a library of swfs that you can load in and use as required. If you make two libraries with the class internally named the same then you can change up your app just by loading in a different library swf. Rob On Thu, 07 Jun 2007 13:39:48 -0400, Patrick Matte|BLITZ [EMAIL PROTECTED] wrote: I want to rename the content because I need to be able to access it later using getChildByName(test); But since its not possible, I think I'll have to make my classes dynamic and do this instead : private function loaderInit(event:Event):void{ event.target.removeEventListener(Event.INIT, loaderInit); this[test] = event.target.content; addChild( this[test] ); } ___ 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