[Flashcoders] Access objects in embedded swf
Hi guys! I'm having a problem accessing movieclips within an embedded SWF. Here is some code: ... [Embed(source = 'portfolio.swf')] public var Portfolio:Class; public function Main() { var portfolio:* = new Portfolio(); addChild(portfolio); portfolio.x = 0; portfolio.y = 0; portfolio.a1.x = 150; // Fails } ... portfolio.a1.x fails, even though there is a movieclip inside portfolio.swf called a1. ReferenceError: Error #1069: Property a1 not found on Main_Portfolio and there is no default value. at Main()[D:\Flash\NewProject\Main.as:19] Any ideas? Thanks in advance! Dav ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Access objects in embedded swf
Dave, Try: portfolio.x = 0; portfolio.y = 0; var child:DisplayObject=portfolio.getChildByName(a1); child.x=150; HTH, Ian On Wed, Apr 15, 2009 at 1:14 PM, Dav d...@funkdaweb.com wrote: Hi guys! I'm having a problem accessing movieclips within an embedded SWF. Here is some code: ... [Embed(source = 'portfolio.swf')] public var Portfolio:Class; public function Main() { var portfolio:* = new Portfolio(); addChild(portfolio); portfolio.x = 0; portfolio.y = 0; portfolio.a1.x = 150; // Fails } ... portfolio.a1.x fails, even though there is a movieclip inside portfolio.swf called a1. ReferenceError: Error #1069: Property a1 not found on Main_Portfolio and there is no default value. at Main()[D:\Flash\NewProject\Main.as:19] Any ideas? Thanks in advance! Dav ___ 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] Access objects in embedded swf
No luck :( -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Ian Thomas Sent: 15 April 2009 13:36 To: Flash Coders List Subject: Re: [Flashcoders] Access objects in embedded swf Dave, Try: portfolio.x = 0; portfolio.y = 0; var child:DisplayObject=portfolio.getChildByName(a1); child.x=150; HTH, Ian On Wed, Apr 15, 2009 at 1:14 PM, Dav d...@funkdaweb.com wrote: Hi guys! I'm having a problem accessing movieclips within an embedded SWF. Here is some code: ... [Embed(source = 'portfolio.swf')] public var Portfolio:Class; public function Main() { var portfolio:* = new Portfolio(); addChild(portfolio); portfolio.x = 0; portfolio.y = 0; portfolio.a1.x = 150; // Fails } ... portfolio.a1.x fails, even though there is a movieclip inside portfolio.swf called a1. ReferenceError: Error #1069: Property a1 not found on Main_Portfolio and there is no default value. at Main()[D:\Flash\NewProject\Main.as:19] Any ideas? Thanks in advance! Dav ___ 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Access objects in embedded swf
Jason Merrill Bank of America Global Learning Shared Services Solutions Development Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Dav Sent: Wednesday, April 15, 2009 8:14 AM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] Access objects in embedded swf Hi guys! I'm having a problem accessing movieclips within an embedded SWF. Here is some code: ... [Embed(source = 'portfolio.swf')] public var Portfolio:Class; public function Main() { var portfolio:* = new Portfolio(); addChild(portfolio); portfolio.x = 0; portfolio.y = 0; portfolio.a1.x = 150; // Fails } ... portfolio.a1.x fails, even though there is a movieclip inside portfolio.swf called a1. ReferenceError: Error #1069: Property a1 not found on Main_Portfolio and there is no default value. at Main()[D:\Flash\NewProject\Main.as:19] Any ideas? Thanks in advance! Dav ___ 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] Access objects in embedded swf
: Property a1 not found on Main_Portfolio What is Main_Portfolio? that seems to be different from Main or portfolio or Portfolio. Does the compiler actually append class and property names together like that or is this a variable someplace else? Jason Merrill Bank of America Global Learning Shared Services Solutions Development Monthly meetings on the Adobe Flash platform for rich media experiences - join the Bank of America Flash Platform Community ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Access objects in embedded swf
In which case you're doing something wrong. :-) That's definitely how it works in AS3 - I use it all the time. To find the child of a DisplayObjectContainer (i.e. a Sprite or a MovieClip) you use getChildByName(), pass in the instance name as set in the timeline. That returns a DisplayObject. If it _doesn't_ return a DisplayObject, you have no child object called that. Then when you have retrieved the child as a DisplayObject, you can manipulate it as required. Are you sure you're on the right frame of Portfolio? Are you sure 'a1' is the instance name on the timeline? Ian On Wed, Apr 15, 2009 at 1:49 PM, Dav d...@funkdaweb.com wrote: No luck :( -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Ian Thomas Sent: 15 April 2009 13:36 To: Flash Coders List Subject: Re: [Flashcoders] Access objects in embedded swf Dave, Try: portfolio.x = 0; portfolio.y = 0; var child:DisplayObject=portfolio.getChildByName(a1); child.x=150; HTH, Ian On Wed, Apr 15, 2009 at 1:14 PM, Dav d...@funkdaweb.com wrote: Hi guys! I'm having a problem accessing movieclips within an embedded SWF. Here is some code: ... [Embed(source = 'portfolio.swf')] public var Portfolio:Class; public function Main() { var portfolio:* = new Portfolio(); addChild(portfolio); portfolio.x = 0; portfolio.y = 0; portfolio.a1.x = 150; // Fails } ... portfolio.a1.x fails, even though there is a movieclip inside portfolio.swf called a1. ReferenceError: Error #1069: Property a1 not found on Main_Portfolio and there is no default value. at Main()[D:\Flash\NewProject\Main.as:19] Any ideas? Thanks in advance! Dav ___ 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 ___ 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] Access objects in embedded swf
Hi, This is a guess, but is it possible that the clip has not had chance to init? I don't know what happens when you instanciate a movieclip like this with children, but if you load a SWF you usually have to wait until the onLoadInit event is dispatched before you can access properties and methods on the movie - could be similar, but correct me if I am wrong. If you only need to access the a1 element of the Portfolio SWF, you could export the library symbol with a LinkageID, republish the swf, then change the [Embed] to only embed the Library symbol - something like [Embed(source = 'portfolio.swf', symbol=a1_symbol)] http://www.bit-101.com/blog/?p=853 HTH Glen Ian Thomas wrote: In which case you're doing something wrong. :-) That's definitely how it works in AS3 - I use it all the time. To find the child of a DisplayObjectContainer (i.e. a Sprite or a MovieClip) you use getChildByName(), pass in the instance name as set in the timeline. That returns a DisplayObject. If it _doesn't_ return a DisplayObject, you have no child object called that. Then when you have retrieved the child as a DisplayObject, you can manipulate it as required. Are you sure you're on the right frame of Portfolio? Are you sure 'a1' is the instance name on the timeline? Ian On Wed, Apr 15, 2009 at 1:49 PM, Dav d...@funkdaweb.com wrote: No luck :( -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Ian Thomas Sent: 15 April 2009 13:36 To: Flash Coders List Subject: Re: [Flashcoders] Access objects in embedded swf Dave, Try: portfolio.x = 0; portfolio.y = 0; var child:DisplayObject=portfolio.getChildByName(a1); child.x=150; HTH, Ian On Wed, Apr 15, 2009 at 1:14 PM, Dav d...@funkdaweb.com wrote: Hi guys! I'm having a problem accessing movieclips within an embedded SWF. Here is some code: ... [Embed(source = 'portfolio.swf')] public var Portfolio:Class; public function Main() { var portfolio:* = new Portfolio(); addChild(portfolio); portfolio.x = 0; portfolio.y = 0; portfolio.a1.x = 150; // Fails } ... portfolio.a1.x fails, even though there is a movieclip inside portfolio.swf called a1. ReferenceError: Error #1069: Property a1 not found on Main_Portfolio and there is no default value. at Main()[D:\Flash\NewProject\Main.as:19] Any ideas? Thanks in advance! Dav ___ 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 ___ 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders