Create a preloader in Actionscript 3.0 Generic

It may seem a predictable and already exhausted, but with Flash CS3 and the new management of document classes (package) permitted in Actionscript 3.0, is not fully functional immediately create a preloader. The latest release of Flash, in fact, manages to load the movie in a different way from previous versions. On the net you can find different proposals and solutions to create a preloader "old school". However, several examples I found did not satisfy me fully as they require to alter the movie so that it works like a classic preloaders. In practice, when you develop must always remember "this thing I have to do so otherwise the preload does not work"! And for movies already filled in, then?

Loader

The solution I have adopted, at least for now, was to make a movie outside (my loader - see example ) able to load any movie outside, including a picture! This solution, although it requires basically two movies (the loader and the FILAME true), it becomes economical only if you can create a loader that can be used over and over again, that is able to upload any movie, any resolution and any frame rate.

Security: swf and images

Remember that if the movie swf to be loaded resides on a different domain from the loader, you have to deal with the security system of Flash. If you use the loader to load the images, however, the problem does not exist. In class I presented there is no control on the sandbox and on the security system, because the loader use the same domain.

: For more information on this subject see Security and LoaderContext :

. The class LoaderContext provides options for loading SWF files and other media by using the class Loader . e loadBytes() della classe Loader . The class LoaderContext is used as a context parameter in the methods load() and loadBytes() class Loader .
When you load SWF files using the method Loader.load() , you must decide which security domain and in which application domain within the security domain you want to place them. . For more information on these options, see the properties applicationDomain and securityDomain . [...]

1. Name of the swf file to load

To create a generic loader is obvious that the name of the movie (like any other information: title, ...) must be passed in some way run. The technique I used is that described in Reading the parameters of a movie in Actionscript 3.0 . In practice we would use:

1
loader.swf? filename = filmato.swf

2. Dimensions

, si può impostare il filmato loader alla stessa risoluzione del filmato da caricare! Setting the stage loader mode StageScaleMode.NO_SCALE , you can set the loader movie at the same resolution of the movie to load! That's all!

3. Frame Rate

When loading the external movie is finished, just run:

1
frameRate = _loader . contentLoaderInfo . frameRate ; internships. frameRate = _loader. contentLoaderInfo. frameRate;

Sources

An example of a class loader is UndoLoader.as . This document can be used as a class in a movie ( loader.fla ), which will contain graphic elements (as complex as you want) of your preloader.

10 comments to "Creating a generic preloader actionscript 3.0"

  1. July 3, 2008 Marcos:

    Eu sou scratch with Flash and AS, bringing with fiquei algumas duvidas, não rola um step by step?

    valeu

  2. August 3, 2008 Peno:

    The files that you download do not work, and an explanation of how to invoke the external file is not at all clear, "loader.swf? Filmato.swf filename =" why in the article "Reading the parameters of a movie in Actionscript 3.0" uses html code?? you could clarify this point? Thank you.

  3. August 4, 2008 Giovambattista Fazioli :

    Peno @: For the parameters indicating loader.swf?filename=nomefilmatodacaricare.swf is purely technical in the sense that tells you to pass as MIME parameters (GET) data to the movie "charger".

    The article you mentioned using an HTML code but depends on the technique 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 movie, you can use various methods:

    1) Use an HTML code Direct
    2) Use your own function that inserts the code dynamically Javascriopt
    3) Use tools such as LightWindow or Shadowbox
    4) Use tools like SWFObject

    For this reason, I simply referred to the "parameter passing" MIME: loader.swf?filename=nomefilmatodacaricare.swf

    The heart of the system, however, is the class UndoLoader.as

    The FLA is an example of its use and it works for me ... that gives you problems?

  4. August 4, 2008 Peno:

    Thanks for the reply, however, given my ignorance on the subject do not understand how to load an external swf using flash-only, so to speak do not know what to change UndoLoader.as.
    . fla file to download it when I try to tell me that it is impossible to publish it and see if it is on a locked disk for writing! which is not!
    Thanks
    Peno.

  5. August 4, 2008 Giovambattista Fazioli :

    Peno @: class Undoloader.as do not have to change, at least you do not need to modify it to make it all work. The main issue is that the class Undoloader.as should be tied to a Flash movie magazine, what you've downloaded as an example. To make it work, you must:

    1) Create a folder and enter this is the. FLA class Undoloader.as
    2) Open the. FLA and check the publish settings, these are likely to cause you some problems

    The movie becomes so filled in the "loading" of what? Of what the steps in the "MIME" when you include it in your page.

    If you give me a valid email address (the one you put me back out) of person I write in more detail.

  6. August 4, 2008 Peno:

    thanks for the availability, this message is guaranteed to work,
    peno78@gmail.com .

    I am suffering.

  7. June 7, 2009 mattia:

    Similar problem:

    Once you download the fla and class, when I try to export the flash movie tells me:

    "Error creating the swf file.
    Make sure the destination file is not locked or located in a locked drive. Also check that the file name is too long. "

  8. June 7, 2009 Giovambattista Fazioli :

    @ Matt: As I said to "I am suffering," check the publish settings of the movie.

  9. February 7, 2010 MB curious:

    I gives me a signal "packages can not be nested"

  10. February 7, 2010 Giovambattista Fazioli :

    @ MB curious weird ... control two sizes not have loaded the same package

Leave a comment

XHTML TAG PERMIT: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERTION CODE:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL