Creating a generic preloader in Actionscript 3.0
Monday, 16 June, 2008
It might seem a foregone conclusion and argument now exhausted, but with Flash CS3 and the new document management classes (package) allowed with Actionscript 3.0, is not entirely immediate create a preloader working. The latest release of Flash, it manages to load the movie so different from previous versions. In network you can find various proposals and ways to recreating a preloader "old". However, several examples that I found I did not fully meet as required to alter the movie to make it work like a classic preloader. In practice when you develop must always remember "this what I have to do so otherwise the preload does not work!" And for movies already completed, then?
Loader
The solution I have adopted, at least for now, was to create a movie outside (my loader - see example) can upload any other movie outside, including a picture! This solution, although in practice requires two movies (the loader and FILAM real), becomes economic only if you manage to create a loader can be used over and over again, that is able to load any movie, any and any resolution frame.
Security: swf and images
Remember that if the movie swf to load is on a different domain from the loader, you'll have to deal with the security system of Flash. If you use the loader to load images, however, the problem does not exist. In class I presented there is no control over the sandbox and system security, as the loader use the same domain.
For more information on this subject see Security and LoaderContext
The class
LoaderContextprovides the necessary options to the loading of SWF files and other multimedia content through the ClassLoaderThe classLoaderContextis used as a parameter in the context methodsload() loadBytes()ClassLoader
When loading the SWF file by the methodLoader.load()you must decide what security domain in which domain and application within the domain of security you want to place them. For more information about these options, see the propertiesapplicationDomainandsecurityDomain[...]
1. Name of the swf file to upload
To create a generic loader is obvious that the name of the movie (as possibly other information: Title, ...) should be passed somehow runtime. The technique I used is described in Reading the parameters of a movie in Actionscript 3.0. In fact, you will:
- loader. swf? filename = movie. swf
2. Size
Setting stage stage of the loader mode StageScaleMode.NO_SCALE you can set the movie loader to the same resolution of the movie to load! That's all!
3. Frame Rate
When loading the external movie is finished simply run:
- = _loader. contentLoaderInfo . frameRate ; stage. framerate = _loader. contentLoaderInfo. framerate;
Sources

An example of a class loader is UndoLoader.as. It can be handled as a class paper in a movie (loader.fla), which will contain graphics (complex as you want) your preloader.





















Marcos said:
Eu sou novo com flash and AS, portanto fiquei com algumas Dúvidas, não um rola step by step?
valeu
Peno said:
The files that you download will work, and explaining how to retrieve the external file is not clear, "loader.swf? Filename = filmato.swf" because in the article "Read the parameters of a movie in Actionscript 3.0" uses html code? you could clarify this point? thanks.
Giovambattista Fazioli said:
Peno @: For the parameters indicating
loader.swf?filename=nomefilmatodacaricare.swfis purely technical in that it shows how to pass parameters MIME (in GET) data to the movie "shipper".In you mentioned use HTML code but depends on the technique that you want to use to show the movie on the page. When you add dynamic content to an HTML page, in this case a flash, you can use several methods:
1) Use an HTML directly
2) Use your function Javascriopt entering the code dynamically
3) Use tools like LightWindow or Shadowbox
4) Use tools like SWFObject
That is why I simply stated the "pass parameters MIME":
loader.swf?filename=nomefilmatodacaricare.swfThe heart of the system, however, is the class
UndoLoader.asThe FLA file is an example of its use and to me it works ... that gives you problems?
Peno said:
Thanks for your answer, but because of my ignorance in the field do not understand how to upload a file using only external swf flash, so not to understand what should change in UndoLoader.as.
the file. fla scrico that when I publish it tells me that it is impossible to control and if it is blocked on a disk write! which is not!
Thank you
Peno.
Giovambattista Fazioli said:
@ Peno: class
Undoloader.asyou do not have to change it, at least there is no need to change it to run everything. The main issue is that the classUndoloader.asbe linked to a flash loader, what you downloaded as an example. Get it all, you must:1) Create a folder and enter this in both. FLA that the class
Undoloader.as2) Open. FLA and check the settings of publication, are those that will probably cause some problems
The movie becomes so filled the "shipper" of what? What the steps in the "MIME" when you put on your page.
If you mail me a valid (the one you entered my return back) will personally write in more detail.
Peno said:
grazie mille for availability, this message does certainly
peno78@gmail.com.
peno.