Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4091802
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:24:45+00:00 2026-05-20T19:24:45+00:00

Sorry about the title, I’m not exactly sure how to explain this with a

  • 0

Sorry about the title, I’m not exactly sure how to explain this with a few words.

I’ve looked through google searches and found that people find it easlier when exporting classes in frame 2 when using a preloader. I’m currently using the usual method of having frame 1 with the preloader, frame 2 with the asset holder and the bulk of the game, frame 3 has the stop(); action. This is the tutorial I followed to get a working preloader AS Gamer.

After many hours of searching I’ve only found mentions and revalations of people using export on frame 2 instead of the traditional asset holder, but no examples or tutorials.

Does any know where I can find a tutorial with example code I reference to get a export on frame 2 preloader?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T19:24:45+00:00Added an answer on May 20, 2026 at 7:24 pm

    I’ve been meaning to write a complete tutorial on the subject of preloaders, but I’m still in the middle of getting my new site launched… until then, here are the hightlights:

    Two parts are going to be required –

    one on the javascript side: sending flashvars into the preloader, and embedding the flash object into the html structure. I love swfobject for its simplicity and its bulletproofness.

    html:

    <html>
      <head>
      <script type="text/javascript" src="/javascript/swfobject/swfobject.js"></script>
      <script type="text/javascript" src="/javascript/logic.js"></script>
      </head>
      <body>
        <div id="flashContainer">content for when swfobject fails</div>
      </body>
    </html>
    

    logic.js:

    var _flashvars  =
        {
            filePath    : "/flash/swf/yourcontent.swf",
            FR          : "60",
            verbose     : "false",
            SW          : "760",
            SH          : "550"
        };
    
    var _params     =
        {
            quality     : 'high',
            menu        : 'false',
            base        : '/flash/swf/'
        };
    
    var _attr =
        {
            id          : "flashContainer"
        };
    
    function embedSWF()
        {
            swfobject.embedSWF(
                    "/flash/preLoader.swf",
                    "flashContainer",
                    "760",
                    "550",
                    "9.0.0",
                    "/javascript/swfobject/expressInstall.swf",
                    _flashvars,
                    _params,
                    _attr 
                    );
            return;
        }
    
    //onload event
    embedSWF()
    

    On the flash side, we have the preloader fla (or however you’re building it). Its purposefully “content-agnostic” because I reuse it for all my preloading. You could save some time by hardcoding in the flash vars, i spose. Anyway, I’ve got two classes –

    Main.as – which pulls in the flashvars at runtime, initiates the load, and then responds to the loading progress, finally adding the loaded content into the display list.

    Preloader.as – which does all the heavy lifting.

    Note these are partial classes pulled directly from my project, and I’ve included only the bare essentials (you’ll have to finish out the code and tailor as needed).

    Note also that this is one of many ways to do this 😉

    Main.as :

     package {
    
                public class Main extends MovieClip 
                {
                    private var _loadParams         :Object;
                    private var _filePath           :String;
                    private var _frameRate          :uint;
                    private var _stageH             :Number;
                    private var _stageW             :Number;
                    private var _verbose            :Boolean;
    
                    public function Main():void 
                    {
                        super();
    
                        if (stage)
                        {
                            init();
                        }
                        else 
                        {
                            this.addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
                        }
                    }
    
                    /**
                     * once preloader is onstage, create param object. 
                     * assign vars from param object
                     * 
                     * stage height / stage width: 
                     * some files may have SH and SW defined, if they are, used them as 
                     * stage dimensions. If they are not, default to current stageHeight,Width
                     * 
                     * @param   e
                     */
                    private function init(e:Event = null):void 
                    {
                        this.removeEventListener(Event.ADDED_TO_STAGE, init);
    
                        stage.align = StageAlign.TOP_LEFT;
                        stage.scaleMode = StageScaleMode.NO_SCALE;
    
                        _loadParams = new Object();
                        _loadParams = LoaderInfo(stage.loaderInfo).parameters;
    
                        _filePath   = String(   parseParam( "filePath", "undefined.swf"             ) );
                        _frameRate  = uint(     parseParam( "FR",       "24"                        ) );
    
                        _stageH         = Number(   parseParam( "SH",       String(stage.stageHeight)   ) );
                        _stageW         = Number(   parseParam( "SW",       String(stage.stageWidth)    ) );
    
                        ( String( parseParam( "verbose", "true" )) == "true")?_verbose = true : _verbose = false;
    
                        initiateLoader();
                    }
    
                    private function parseParam(name:String, defaultValue:String):String
                    {
                        if (_loadParams.hasOwnProperty(name) && _loadParams[name] != "" && _loadParams[name] != "undefined") 
                        {
                            return _loadParams[name];
                        }
                        else
                        {   
                            return defaultValue;
                        }
                    }
    
                    private function initiateLoader():void
                    {
                        _loader = new PreLoader(_filePath, _verbose);
                        _loader.addEventListener("displayObjectLoaded", onLoadComplete, false, 0, true);
                        this.addEventListener(Event.ENTER_FRAME,    setLoadPercentage,  false,  0,  true); 
                    }
    
    
                    /**
                    * respond to load graphically
                    */
                    private function setLoadPercentage(e:Event):void 
                    {
                        _loadPercentage = Math.round((_loader.progressNumberArray[0] /_loader.progressNumberArray[1])*100);
                        if (_verbose)
                        {
                        _txt.text = String(_loadPercentage) + "% Loaded";
                        }
                    }
    
                    /**
                     * finally, add the loader object into the display list.
                     */
                    private function onLoadComplete(evt:Event):void 
                    {
                        _loader.removeEventListener("displayObjectLoaded", onLoadComplete);
                        this.removeEventListener(Event.ENTER_FRAME, setLoadPercentage);
    
                        this.addChild(_loader);         
                    }
    

    Preloader.as

    package {
    
        import flash.display.*;
        import flash.events.*;
        import flash.net.URLRequest;
        import flash.text.TextField;
    
        public class PreLoader extends Sprite {
    
            private var _loader             : Loader;
            private var _loaderInfo         : LoaderInfo;
            private var _verbose            : Boolean = false;
            private var _loadProgressString : String = "";
            private var _bytesLoaded        : Number = 0;
            private var _bytesTotal         : Number = 0;
    
            public function PreLoader(path:String, verbose:Boolean) 
            {
                _verbose    = verbose;
    
                _loader     = new Loader();
                _loaderInfo = _loader.contentLoaderInfo;
    
                    // there are several other events to listen for and respond to
                _loaderInfo.addEventListener(ProgressEvent.PROGRESS,    onProgress, false, 0, true);
                _loaderInfo.addEventListener(Event.COMPLETE,            onComplete, false, 0, true);
    
                try 
                {
                    _loader.load(new URLRequest(path));
    
                } 
                    catch (evt:Error) 
                {
                    _loader.unload();
    
                    var errMsg:TextField = new TextField();
                    with (errMsg) {
                        width       = 300;
                        text        = "Unable to load content:\n" + evt.toString();
                    }
                    addChild(errMsg);
                    dispatchEvent(new Event("displayObjectLoaded"));
                }
            }
    
                private function onProgress(evt:ProgressEvent):void 
            {
                var loadPercent:int = Math.round((evt.bytesLoaded / evt.bytesTotal) * 100);
                _bytesLoaded        = evt.bytesLoaded;
                _bytesTotal         = evt.bytesTotal;
                _loadProgressString = (loadPercent + " % loaded: " + _bytesLoaded + " bytes of " + _bytesTotal + " total bytes");
                if (_verbose) 
                    {
                    trace(_loadProgressString);
                }
            }
    
    
            private function onComplete(evt:Event):void 
            {
                _loaderInfo.removeEventListener(Event.COMPLETE,         onComplete);
                _loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);
    
    
                addChild(_loader);
                dispatchEvent(new Event("displayObjectLoaded"));
            }
    
                /**
                 * getter for load details
                 */
            public function get progressNumberArray():Array 
            {
                return [_bytesLoaded,_bytesTotal];
            }
    

    Hopefully that helps get you started. Let me know if you have any questions.

    cheers!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sorry about the title I'm just not sure how to describe this one.
Sorry for this not being a real question, but Sometime back i remember seeing
Sorry, I'm new to SVN and I looked around a little for this. How
Sorry for the second newbie question, I'm a developer not a sysadmin so this
Sorry about the poor title ;) I'm trying to recreate a matlab plot I've
Sorry about the vague question title, but I have these typedefs here: typedef std::list<AnimationKeyframe>
I really didnt know what to put to the title so sorry about that.
Sorry about the vague subject but I couldn't think what to put. Here's my
Sorry the title isn't more help. I have a database of media-file URLs that
Sorry if this sounds like a really stupid question, but I need to make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.