views:

400

answers:

1

I've a flash movie that I would like to use inside of a flex application, very similar to a preloader.

Looking at this tutorial, http://www.flexer.info/2008/02/07/very-first-flex-preloader-customization/, I expected it would be a matter of not extending "Preloader" and extending "Sprite" and using the class i created wherever i needed.

Alas, the movie I created, is not being shown.

This is the code for my class containing the movie, made based on the tutorial above:

package 
{
    import mx.preloaders.DownloadProgressBar;
    import flash.display.Sprite;
    import flash.events.ProgressEvent;
    import flash.events.Event;
    import mx.events.FlexEvent;
    import flash.display.MovieClip;


    public class PlayerAnimation extends Sprite
    {
     [Embed("Player.swf")]
     public var PlayerGraphic:Class;

     public var mc:MovieClip;

     public function PlayerAnimation():void
     {
      super();
      mc = new PlayerGraphic();
      addChild(mc);
     }

     public function Play():void
     {
      mc.gotoAndStop(2);
     }
    }
}
A: 

you need to take into account that flex's basic display primitive is UIComponent, as opposed to Flash that uses mainly Sprites. You can only add a UIComponent to a Flex component (and not directly a Sprite, as you seem to be trying to do).

you should:

var iui:UIComponent=new UIComponent(); //first create the UIComponent container var player:PlayerAnimation=new PlayerAnimation(); //then create your Sprite-based class player.width=this.width; player.height=this.height; //set-up height,width iui.addChild(player); //add your Sprite-based class to the UIComponent this.addChild(iui); //finally you can add the UIComponent to your Flex Container (Application, TitleWindow, VBox, Panel... whatever it is)

elias