Help with FlashVars in AS3
Well I've read a few of the threads on accessing flashvars with AS3 and am still grappling with it, I'm hoping someone who has tackled this will take mercy on my poor soul and help me out.
Essentially I've inherited making some changes to a flash file (a cover loader, carousel, media player thingy) that was built by a couple of other developers and am stumbling around - and I'm new to AS3.
The project is constructed with a number of classes and packages and I have imported the LoaderInfo / import flash.display.LoaderInfo;
and assumed I could simply access the flashvars like this:
public var loadV = root.loaderInfo.parameters.loadVideo;
where loadV becomes the value I pass into the function that tells the carousel which cover to stop on. and loadVideo is the flashvar value in the html page
I also tried this approach, but neither worked for me:
public var flashvars:Object = LoaderInfo(this.root.loaderInfo).parameters;
public var tloadVideo = flashvars['loadVideo'];
same post as above : I edited attempting to be more clear
well probably not the prettiest solution but eventually got it working.
In the document class where the flashvar was declared I have an initHandlers function that called the preloader and a movie to the stage from another init function in the loadXML class...
so I added the flashvar as a param in that method call from the doc class, which handed it off to the loadXML:
movie.init(stage, loadV); //where loadV is the value of the flashvar
then in the main init function the var is passed as the second param:
public function init(myStage:Stage, myFlashVar:String):void
{
if(myFlashVar != null || myFlashVar != undefined){
var xmlPath:String = "/filepath/xml/"+myFlashVar+".xml";
}else{
var xmlPath:String = "/filepath/xml/filename.xml";
}