title: Load and play embedded SWF file in Flex / Actionscript
body: <p>I'm trying to create / use a pre-loader in my flex application.  The preloader is a SWF file which has 100 frames (1 for every percent of the loader progress).  Basically I am trying to Embed this SWF file in my application, display it on screen and change the frame number being displayed as the progress completes.</p>
  
  <p>The code I have so far is (which extends Canvas): </p>
  
  <pre><code>[Embed("/../assets/preLoader.swf")]
  private var SWFClass:Class;
  
  private var _preLoader:MovieClip;
  
  private var _progress:Number;
  
  public function set progress(value:Number) : void {
      _progress = value;
  
      if(progress &lt; 100) {
          _preLoader.gotoAndPlay(progress, null);
      }else {
          _preLoader.gotoAndStop(0, null);
      }
  }   
  
  [Bindable]
  public function get progress() : Number {
      return _progress;
  }
  
  
  
  (Called on creationComplete event)          
  private function init() : void {
      _preLoader = MovieClip(new SWFClass());
  
      this.addChild(_preLoader);
  
      _preLoader.play();
  }
  </code></pre>
  
  <p>The error I am getting is:</p>
  
  <pre><code>TypeError: Error #1034: Type Coercion failed: cannot convert widgets::PreLoader_SWFClass@30b3be51 to mx.core.IUIComponent.at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChild()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:3259]
  </code></pre>
  
  <p>Please help!</p>