Hi Glen,
   If it's just on stage, you don't need to wait for an init() on an
embedded clip - it's available instantly (which is nice!). Unless
you're moving to another frame, in which case you need to wait (off
the top of my head for a FRAME_CONSTRUCTED, I think).

Ian

On Wed, Apr 15, 2009 at 2:15 PM, Glen Pike <g...@engineeredarts.co.uk> wrote:
> 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
>

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to