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 7607093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:34:30+00:00 2026-05-31T00:34:30+00:00

I want to call a function in main flex app from the custom preloader

  • 0

I want to call a function in main flex app from the custom preloader code in actionscript before it dispatches complete event.
Also i want to know how to call back to a function in preloader code from application

Thanks

  • 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-31T00:34:31+00:00Added an answer on May 31, 2026 at 12:34 am

    So in the preloader init method you can use the following line to get the application:

            parentApplication = event.currentTarget.loaderInfo.content.application;
    

    we had our preloader implement a custom interface called IPreloader and our App implement a custom interface called IPreloaderApp, IPreloader is defined as:

    package com.roundarch.adapt.preloader
    {
        import mx.preloaders.IPreloaderDisplay;
    
        public interface IPreloader extends IPreloaderDisplay
        {
            /**
             * Setting this will update the preloader's percentage bar or graphic.
             */
            function set percentage(value:Number):void;
            function get percentage():Number;
    
            /**
             * Sets the status (if available) on the preloader.
             */
            function set status(value:String):void;
    
            /**
             * This will communicate to the preloader that loading of all application
             * properties is complete.
             */
            function loadingComplete():void;
    
            /**
             * This will tell the preloader that there has been an error loading the application.
             *
             * The preloader will probably want to display this error message in a nice display to
             * the user.
             *
             * @param errorString The error message to display.
             * @param fatal If true, the preloader should act as if the application will not run perhaps
             * by notifying the user that they cannot continue.
             * @return Should return true if the error was properly handled.
             */
            function displayError(errorString:String, fatal:Boolean=false):Boolean;
    
            /**
             * Returns true if this IPreloader implementation can handle displaying loading
             * errors through the error(...) method. If false, the implementing application will
             * need to notify the user of any errors itself.
             */
            function get canDisplayErrors():Boolean;
        }
    }
    

    and for the IPreloaderApp

    package com.roundarch.adapt.preloader
    {
    
        /**
         * Any application which uses an IPreloader as its preloader will be
         * required to implement this interface or throw an error.
         */
        public interface IPreloaderApp
        {
            /**
             * Once the application has loaded and initialized, this method will be called on the
             * application and the preloader will be passed in so the app can make updates to it.
             */
            function preloaderInit(preloader:IPreloader):void;
        }
    }
    

    Also something to note, if the app is added behind the preloader instead of in-front (the default behavior) then you won’t see alerts that are popped up by the application since they’ll be behind the preloader so you’ll want to switch the order. Here’s a bit of code we used to get around that:

        private var removedOnce : Boolean;
    
        //When the Preloader class instance (this things parent) is removed from it's parent
        //add this to the stage, allows us to dispatch the complete event at the corret time
        //allowing the SystemManager to add the application to the stage and adding this at
        //index 0 to allow pop-ups to show over it.
        private function parentRemoved(event : Event) : void
        {
            if (!removedOnce)
            {
                removedOnce = true;
    
                stage.addChildAt(this, 0);
                ToolTipManager.enabled = false;
            }
        }
    

    after the parentApplication is set within the preloader init handler as shown at the top of this post we add a handler to catch the removal of the preloader by the SystemManager and re-add it (there is no visible flicker)

            //Lets the system manager know to add the application to the stage
            //this will also remove the preloader for this reason I'm listening for the removal
            //then adding the preloader to the stage again
            parent.addEventListener(Event.REMOVED, parentRemoved);
            dispatchEvent(new Event(Event.COMPLETE));
    

    One other thing to note is that you don’t want to “pollute” your preloader code with any Flex classes, if you include things from the framework you will end up having to load the entire framework into memory before the preloader begins (which can be hefty).

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

Sidebar

Related Questions

How do I call a custom component's public function from the main app. For
I want to call AS function from JS. I have the following ActionScript 3
I want to call a C classes main function from within another class (which
I want to call a function from a .NET DLL (coded in C#) from
I want to call a c# function from my javascript function. I have a
I want to call a controller function from a view. Is that possible in
Actually i want to call a function of one activity from another activity..i write
I want to call a C function from C#. C function is inside a
I want call a function which makes my main thread stuck using the above
When I want to call a function from a dynamic linked library, I'm using

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.