tags:

views:

119

answers:

2

I am having a problem with preloaders showing up in my flex apps. I never had this problem when developing flash apps so I got the idea to use a flash app as a shell with the sole purpose of showing a preloader while the flex app loads. I am not sure how to do this though, and I also need to ba able to pass the FlashVars from the shell flash app to the flex app. Does anyone know how this can be done?

Thanks!!

A: 

Flex supports preloaders through the Application class, so you shoudn't have to resort to a hack. It's described in detail in the Flex 3 Developer Guide, Ch. 14 ("Application Container"). I never programmed a pure Flash preloader, but I figure it's different from what Flex does. Maybe the two of them conflict?

Simon
A: 

I am going to begin by agreeing with Simon, but there are ways to create the hack you're talking about.

Unfortunately, the parent layer to the Application in Flex overrides numChildren so that it always returns -1. This means that you are neither able to access the parent swf from flex, nor are you able to directly access the descendant SWF from Flash (amusingly, if a Flex App loads a Flash swf, this is not a problem).

The way around this:

  1. Create a custom event. Set bubbling to true and cancelable to false.
  2. Add an event listener for that event on the Flash layer.
  3. Dispatch that from the Application layer of the Flex App.
The function which handles that event can now use the target property of the event to access the Application layer of the Flex App.

Christopher W. Allen-Poole