views:

1306

answers:

3

I want to access some flashvars in my preloader to a Flex application. How is this possible?

Regards Adlertz

+2  A: 

Try the loaderInfo.parameters attribute of the preloader.

David Hanak
+1  A: 

From the preloader, you should be able to access the flashvars indirectly through the SystemManager as follows:

var systemManager:SystemManager = parent.parent as SystemManager;
var params:Object = LoaderInfo(systemManager.loaderInfo).parameters;
Raul Agrait
I think the loaderInfo attribute of all sprites in the display tree point to the same LoaderInfo instance, so there is no need to dig up the system manager. But I could be wrong.
David Hanak
A: 

I have accessed the flashvars using loaderinfo from the root of my preloader-sprite.

var flashvars:Object = root.loaderInfo.parameters;

The tricky part was to know when the root wasn't null. But I found a blogpost:

http://dndigital.net/blog/2008/08/accessing-flashvars-in-a-custom-flex-preloader/

root.loaderInfo is the same as loaderInfo, when root is not null, see my comment to Raul's answer.
David Hanak