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

Reply via email to