A stand alone flash player

Here I need to make a flash stand-alone player that will play on PC and Mac. It will import a .swf that itself nests a .flv.

package {
  import flash.display.*;
  import flash.net.*;
  import flash.system.fscommand;
  public class basic_standalone extends MovieClip {
    public function basic_standalone () {
      var request:URLRequest = new URLRequest("themovie.swf");
      var loader:Loader = new Loader();
      //This next line prevents the viewer from rescaling the content but in Mac
      //you can still scale the .app window.
      stage.scaleMode = StageScaleMode.NO_SCALE
      fscommand("showmenu","false");
      loader.load(request);
      addChild(loader);
    }
  }
}

I had to add a mask the size of the stage and an empty sublayer to prevent assets being viewed outside the stage area if the user decided to scale the viewing window. I’d like to prevent the viewer from resizing the window but outside of using Director I haven’t found a good way to do it yet.

References:

http://blog.0tutor.com/post.aspx?id=96&titel=Dynamic-import-flash-content-with-AS3


Posted: June 6th, 2008 | Author: | Filed under: Code Reference | No Comments »

FLV’s don’t always work with relative pathing in XP browsers.

Say you want to create a Flash .swf that references a .flv with relative path. What you may discover, if you’re trying to view the .swf on a PC/Windows XP, is that the .flv does not play – and this is the case with Firefox, IE6, IE7, and Safari. But you may discover that it will work on Mac with Safari and Firefox! Also, you may discover that it will work on Vista on the same browsers!

So, the flash with .flv doesn’t work on PC XP with browsers Firefox, IE6, IE7, or Safari. But it does work on Mac Firefox and Safari as well as Vista Firefox, IE7, and Safari.

Why is this? I don’t know. But it seems that the problem is that the files reside locally. A work-around that I used was to post the files on a web server. I also discovered that it will work if accessed through FTP.

Arg!


Posted: June 4th, 2008 | Author: | Filed under: Code Reference | No Comments »

A simple MOD function for Flash

private function modfunction(n:Number,b:Number):Number {
  //****** MOD FUNCTION
  // n = number to apply the mod function to. b = base of for the mod function
  var result:Number = new Number();
  result = n - b*(Math.floor(n/b));
  return result;
}

Posted: June 2nd, 2008 | Author: | Filed under: Code Reference | No Comments »