PDA

View Full Version : Pure AS3 in Flex -- Preloader?


ramonboss
06-01-2007, 07:28 AM
Hi,

I would like to get some help from you gurus about an issue I found no
response in any of my forum or google searches.

I created a pure actionscript application in Flex 2.01 to start getting
acquainted with AS3. This application is now a big monster that loads images,
XML files, sound, etc. However, as I said, this is just actionscript inside
FLEX.

That is, I have a main SWF created in Flex that is embeded in the web page which
loads the rest of th assets...

Everything works perfectly except for the fact that my main pure actionscript SWF
do not have a PRELOADER. It is only about 90k but still I get this nastly empty
screen with nothing on it for a few seconds and I would like to add a preloader.

How do I implement a preloader in a pure actionscript Flex application?

Thanks

Ramon Lopez

flexy
06-01-2007, 09:18 AM
Given your approach, you could do one of two things:

1) Create a separate SWF that is simply tasked with loading your main SWF. Could be simpler, and probably wouldn't take as long to appear on screen, as it wouldn't be loading lots of classes.

2) Use Flex's in-built preloaders package to put one inside your app to handle the download and initialisation. http://livedocs.adobe.com/flex/201/langref/mx/preloaders/Preloader.html

ramonboss
06-01-2007, 11:25 AM
I already tried the first way and I get this funny message about trying
to reach an object that is null. I already checked it out and the problem
is in the stage property of the main sprite class. Flash CS3 complains
about me using the stage property to set the initial resizing characteristics
of the Flex SWF. I know I could do this from the Flash CS3 preloader but
that would require me to make major changes in my Flex main pure
actionscript application to eliminate references to the stage property of
any of the displaycontainers I use. A real pain in th ass!

So I will try the other way and I will let you guys know.

Bye
Thanks
Ramon Lopez

dr_zeus
06-01-2007, 06:00 PM
Please note that saying "a pure actionscript Flex application" is confusing. I assume that you mean that you're using an ActionScript Project in Flex Builder, but others may interpret that differently. "Flex Builder" should not be shortened to "Flex" because "Flex application" implies that you're using the Flex framework.

Assertnfailure
06-01-2007, 06:13 PM
You're going to be in for some headaches with a pure actionscript flex project...especially once you start trying to populate components with sub-components while dealing with the asynchronous nature of flex 2 component instantiation.

omarfouad
12-27-2008, 03:16 AM
if you are doing flash content there is a nice approach right here
http://omar-fouad.net/blog/?p=69

Persuader
12-27-2008, 10:43 AM
Wow, talk about resurrecting a dead topic.

I wish I had seen it before though, the stage issue has already been somewhat explained here and would have saved me some degree of hassle on this TOPIC (http://www.actionscript.org/forums/showthread.php3?t=192661).
Oh well.

starpause
02-04-2009, 11:40 PM
How do I implement a preloader in a pure actionscript Flex application?


the cleanest preloader for a pure as3 application which i've found is this example by Omar

http://omar-fouad.net/blog/?p=69

which is based on the FlashDevelop “ActionScript 3 Project with Preloader” template. tried and true!

the only thing I do differently from Omar is name Preloader whatever my project is called, so when I publish the swf I have WhateverProject.swf instead of another random Preloader.swf