Click here to Skip to main content
15,895,084 members

Load external pictures without interfering in the work the user is doing

MRS1989 asked:

Open original thread
I want to load external pictures (that will end up changing periodically) without interfering with the end-user's work in Adobe Flash. What I want would be similar to Multi-Threading technology in the Programming Languages.
I am using the following code for load external pictures:
private var ldrExternalPreloader:Loader;
private var pictureHolderMovieClip:MovieClip;
private var showPreloader:Boolean;
private var preloaderMovieClip:MovieClip;
private var progressIndicator:TextField;

public final function Preloader(strFilePathName:String, mcPictureHolder:MovieClip, bolPreloader:Boolean = true, mcPreloader:MovieClip = null, txtDynProgressIndicator:TextField = null):void 
{
    ldrExternalPreloader = new Loader();
    ldrExternalPreloader.load(new URLRequest(strFilePathName));

    filePathName = strFilePathName;
    fictureHolderMovieClip = mcPictureHolder;
    showPreloader = bolPreloader;
    preloaderMovieClip = mcPreloader;
    progressIndicator = txtDynProgressIndicator;

    if (bolPreloader)
    {
        if (mcPreloader != null)
        {
            mcPreloader.visible = true;
        }
        trace("*************************" + " External Preloader Informtion " + "*************************");
        ldrExternalPreloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, ldrExternalPreloader_Progress);
        trace("**************************************************");
    }
    ldrExternalPreloader.contentLoaderInfo.addEventListener(Event.COMPLETE, ldrExternalPreloader_Complete);
}

private function ldrExternalPreloader_Progress(progEvent:ProgressEvent):void 
{
    var numProgressCompletePercent:Number = Math.floor((progEvent.bytesLoaded * 100) / progEvent.bytesTotal);

    if (progressIndicator != null)
    {
        progressIndicator.text = numProgressCompletePercent + "%";
    }

    if(preloaderMovieClip is MovieClip && preloaderMovieClip != null)
    {
        preloaderMovieClip.gotoAndStop(numProgressCompletePercent);
    }
    trace("Progress Completed (%): " + numProgressCompletePercent + "%");
    trace(progEvent.bytesLoaded + " Bytes of " + progEvent.bytesTotal + " is Loaded.");
}

private function ldrExternalPreloader_Complete(event:Event):void 
{
    pictureHolderMovieClip.addChild(ldrExternalPreloader);

    if (showPreloader)
    {
        if (preloaderMovieClip != null)
        {
            preloaderMovieClip.visible = false;
        }
        ldrExternalPreloader.removeEventListener(ProgressEvent.PROGRESS, ldrExternalPreloader_Progress);
    }
    ldrExternalPreloader.removeEventListener(Event.COMPLETE, ldrExternalPreloader_Complete);
}

And I use it with the following line of code:
Preloader("Images/Previews/PC.png", mcContents.mcTransition.mcTransitionAni.mcLeftPreviews, true, mcPreloader, mcPreloader.txtDynProgressIndicator);

I only want to know if loading external pictures with this method interferes in the GUI/UI that the user is working in while in Adobe Flash Player or Adobe AIR, or not?
Tags: Flash, Flex

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900