New Media Fun

Having fun in an online world

Archive for January, 2010

FlashVars Simplified

Posted by admin under Flash

Today, I was having a frustrating time finding a clear method flashVars code snippet. With some trial and error, I finally had success with a simple method to grab variables from the html embedding code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
package{
 import flash.display.LoaderInfo;
 import flash.display.Sprite;
 
 public class DocumentClass extends Sprite{
  private var _myflashVar:String = LoaderInfo(root.loaderInfo).parameters.myVar;
 
  public function DocumentClass(){
   if(_myflashVar == null){
    _myflashVar = "ERROR"
   }
  }
 }
}

Hope this helps anyone out there.