2 Replies Latest reply on Mar 9, 2010 1:56 AM by Ibarim

    Replacing mxml SWFLoader with AS

    Ibarim Level 1

      Hi,

      I'm creating an SWFLoader instance on stage using mxml syntax. I'm using this swfLoader to display an MC from external .swf file. I need to be able to control MC's time line with 'start()' and 'stop()' commands. I read that the way to do this is by creating a MovieClip instance and assigning imported swf to it. So my code looks like this:

       

      MXML:

      <mx:SWFLoader id="myMC_3" source="{myMC_2}" />
      

       

      AS:

      [Embed(source="some_swf.swf", symbol="myMC_1")]
      [Bindable]
      private var myMC_2:Class;
      
      myMC_4 = myMC_3.content as MovieClip;
      

       

      And this works fine. But when I'm trying to create SWFLoader instance using only AS (without mxml) it doesn't work - an error appears telling me that 'myMC_1.content' is null.

       

      AS:

      [Embed(source="some_swf.swf", symbol="myMC_1")]
      [Bindable]
      private var myMC_2:Class;
      
      myMC_3 = new SWFLoader;
      myMC_3.source = "Embed(source='myMC_2')"
      
      myMC_4 = myMC_3.content as MovieClip;          //here it stops on an error telling me that 
                                                     //I cannot assign null property
      

       

      Any ideas what's wrong or have You any proposition how to control external MC inside Flex with SWFLoader created only with AS (Without MXML)?