Oh the joy ahaha, Dont worry if your reading this thinking omg not another flashVars question, thats cool I have that working not a problem.
My question lies with passing these variables in to the loaded SWF, I have a simple preloader with the actions on the first frame and from this im gathering my paths
import com.arthropod.Debug;
//************************************************************************************//
// START OF PRELOAD CONTENT //
//************************************************************************************//
// Create varaibles for the loader
var perc:Number;
var preloaderPerc:Number;
var cf = preloader_mc.progress_mc.currentFrame;
var tf = preloader_mc.progress_mc.totalFrames;
var loader:Loader = new Loader();
// Create variables for flashVars
var _xmlPath:String;
var _imgPath:String;
var _swfPath:String;
// Add the event listeners to the loader
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
loader.load(new URLRequest("document.swf"));
//************************************************************************************//
// CREATE LOOP FUNCTION TO CHECK IF THE EXTERNAL FILE PROGRESS //
//************************************************************************************//
function loop(e:ProgressEvent):void
{
var bt = e.bytesTotal;
var bl = e.bytesLoaded;
perc = bl / bt ;
preloaderPerc = Math.floor( ( bl * 100)/ bt )
preloader_mc.progress_mc.gotoAndStop(preloaderPerc);
}
//************************************************************************************//
// CREATE COMPLETE FUNCTION FOR WHEN THE LOAD IS COMPLETE //
//************************************************************************************//
function done(e:Event):void
{
// Set the percentage to null
// percent = null;
// Create new Bitmap instance of the stage
var bitmap:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight);
bitmap.draw(stage);
// Create new Bitmap
var bitmapNew:Bitmap = new Bitmap(bitmap);
// Add the following
addChild(loader);
addChild(bitmapNew);
//Now we have a snapshot of the current frame
//on TOP of the new thing
removeChildAt(0);
//So we can get rid of the real old frame
//Now we just fade out the snapshot!
var timer:Timer = new Timer(20,20);
// Add the event listeners for the timer event
timer.addEventListener(TimerEvent.TIMER, function()
{
bitmapNew.alpha -= 0.5;
});
timer.addEventListener(TimerEvent.TIMER_COMPLETE,function()
{
removeChild(bitmapNew);
});
//and delete it after it's faded completely.
timer.start();
// Access the flashVars
initFlashVars();
}
//************************************************************************************//
// INITIALISE THE FLASH VARS FROM THE HTML FILE //
//************************************************************************************//
function initFlashVars():void
{
_xmlPath = root.loaderInfo.parameters["xmlPath"];
Debug.log(_xmlPath , 0x00CCCC);
_imgPath = root.loaderInfo.parameters["imgPath"];
Debug.log(_imgPath , 0x00CCCC);
_swfPath = root.loaderInfo.parameters["swfPath"];
Debug.log(_swfPath , 0x00CCCC);
}
I now want to pass these in the the document.swf that uses a Document.as class, however I am aware that i would need to traverse down to my preloader to get these variables and this is where im struggling.
Would any one be able to shed any light on this??
Thank you