views:

2061

answers:

2

I want to incorporate a Flash Pre-loader in my application, but I am using only Flex SDK/AS3/Notepad to code this beast. I don't have access to the Flash IDE.

There are many tutorials and helpfiles online for how to do it within CS4, but not in the code itself. Can anyone give me direction here?

Most examples seem to pivot around placing a loader symbol into the first frame, before the rest of your application - but I don't have access to the timeline or frames from within flex (or at least, I don't think I do!).

+3  A: 

You will want to read about some of the AS3 compiler directives--the relevant one in this case being factory class.

Essentially, you will need to create a class to load your main class that extends MovieClip. The 'preloader' class can monitor the bytesloaded/bytestotal and then instantiate your main class. The non-intuitive portion of this (for me at least) was including the diective: [Frame(factoryClass="pathToYourLoaderClass")]

in the top of your main class you want to preload.

Below is a great blog with more info and a good solution.

http://www.bit-101.com/blog/?p=946

philip
Looks like the solution is probably a bit too complex for what I want to deal with, and none of the resources I could find would deal with Flex SDK 3 - most deal with Flex 2 (including this bit-101 link) and even more AS2 instead of AS3. Thanks though!
Andy Moore
FYI this functionality hasn't changed since Flex2. To incorporate a preloader made with the Flash IDE:1. Create the preloader asset as a movieclip in flash and export it as a SWC2. Include the swc in your library path in the flex project http://tiny.cc/L941T3. Inside your factory class's EnterFrame event, you can instantiate and then increment the frame of the swc preloader using the BytesLoaded/BytesTotal of the factory class.It's tedious, but easy to abstract as a Class for re-usability
philip
+2  A: 

For flex applications you set the preloader property of the application. This is usually the boring grey progress bar but can be any display object. Keep in mind though that for the preloader to actually show it has to be loaded and hence needs to be kept small. Thus, it is not recommended to use any classes that are part of the Flex framework as the framework must then be downloaded before the preloader can show.

If you're doing a straight up AS3 project with no Flex at all, then you'll want to take a look at the Frame metadata tag. Look here for more information:

http://www.bit-101.com/blog/?p=946 http://blogs.adobe.com/rgonzalez/2006/06/modular_applications_part_2

macke