title: Flixel - How to load and play an embedded swf file
body: <p>I have been searching the web and all of the codes I have found are to play external swf files that have a timeline. The file that I am trying to load does not have a timeline. I am using the Flixel framework for this project and the file that I want to play is also made in Flixel(don't have the source file just the swf file).</p>
  
  <p>Most of the code I have is from a cutscene template that I found on the Flixel forum. Here is what I have so far:</p>
  
  <pre><code>package  
  {
  import org.flixel.FlxState;
  import org.flixel.FlxG;
  import flash.display.MovieClip;
  import flash.media.SoundMixer;
  import flash.events.Event;
  
  public class SponsorsState extends FlxState 
  {
  
      //Embed the cutscene swf relative to the root of the Flixel project here
      [Embed(source='assets/DirtPileLogo.swf', mimeType='application/octet-stream')] private var SwfClass:Class;   
      //This is the MovieClip container for your cutscene
      private var movie:MovieClip;
      //This is the length of the cutscene in frames
      private var length:Number;
  
      override public function create():void
      {
          movie = new SwfClass();
          //Set your zoom factor of the FlxGame here (default is 2)
          var zoomFactor:int = 2;
          movie.scaleX = 1.0/zoomFactor;
          movie.scaleY = 1.0 / zoomFactor;
          //Add the MovieClip container to the FlxState
          addChildAt(movie, 0);
          //Set the length of the cutscene here (frames)
          length = 100;
          //Adds a listener to the cutscene to call next() after each frame.
          movie.addEventListener(Event.EXIT_FRAME, next);
      }
      private function next(e:Event):void
      {
          //After each frame, length decreases by one
          length--;
          //Length is 0 at the end of the movie
          if (length &lt;= 0)
          {
              //Removes the listener
              movie.removeEventListener(Event.EXIT_FRAME, next);              
              //Stops all overlaying sounds before state switch
              SoundMixer.stopAll();
              //Enter the next FlxState to switch to
              FlxG.state = new PlayState();
          }           
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>When I run this I get this error: <code>Type Coercion failed: cannot convert SponsorsState_SwfClass@fb5161 to flash.display.MovieClip.</code>, all I want to do is play the swf file for a set frame count then move onto the next state.</p>
  
  <p>Any ideas on how to do this?</p>