1 Reply Latest reply on Aug 12, 2010 10:47 AM by weizhangstrobe

    OSMFplayer sample - getting it to compile...problems anyone?


      I don't use flex or flash builder. If you do perhaps it all runs fine.

      OSMF presents itself as a pure actionscript library. Quite a few of the samples use flex/flash builder.

      The OSMFplayer sample in the SVN is an actionscript only project.

      So I set it up FlashDevelop, which is what I usually work in.


      To get it to compile I found I needed to do the following:


      Created a document class:

          import flash.display.Sprite;
          import flash.events.Event;
          import org.osmf.player.preloader.Preloader;

          public class Main extends Sprite
              public var pre:Preloader
              public function Main():void
                  if (stage) init();
                  else addEventListener(Event.ADDED_TO_STAGE, init);
              private function init(e:Event = null):void
                  removeEventListener(Event.ADDED_TO_STAGE, init);
                  // entry point
                  pre = new Preloader();


      Then had to amend the Preloader class constructor.

      Amend was: move everything after the super call to another function, calling this other function once the Preloader Event.ADDED_TO_STAGE has fired.

      Without doing this on compiling I was getting an error about a null object (that'd be the stage).


      public function Preloader()
                  // Set the SWF scale mode, and listen to the stage change
                  // dimensions:
                  addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
              private function onAddedToStage(e:Event):void
                  removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
                  stage.align = StageAlign.TOP_LEFT;
                  addEventListener(Event.ENTER_FRAME, progressDrawingEventHandler);
                  stage.addEventListener(Event.RESIZE, progressDrawingEventHandler);
                  loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressDrawingEventHandler);
                  loaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
                      _debugger = new Debugger(loaderInfo.parameters["id"]);


      Perhaps no-one else has had problems getting this to compile.

      The dev docs say that using this OSMFplayer sample is a good place to start with OSMF. So perhaps it is useful to post about problems compiling it.