MovieClipLoader Oddity in Flash Lite 2

Jeff from Custom Logic posted on the Flash Lite mailing list about a problem with MovieClipLoader. Basically, if you remove the MovieClip via removeMovieClip that is used in the load operation for the MovieClipLoader.loadClip, as soon as the image loads, you’ll get a “Unable To Load Data” error. For some reason this race condition is handled fine in Flash Player 9 and below, as well as the Flash Lite emulator in Flash 8, but not in Flash Lite 2.

Solution is to encapsulate the load operation & removing of the MovieClip in a class that generates an event upon success since it cannot happen immediately.

Non-class example (tested and works):

function init()
{
        mcl = new MovieClipLoader();
        mcl.addListener(this);
        
        load_btn.onPress = function()
        {
                this._parent.doLoad();
        };
        
        kill_btn.onPress = function()
        {
                this._parent.doKill();
        };
        
        // keep state
        abortFurtherLoading = false;
        isLoading = false;
        
        fscommand2("FullScreen", true);
        
}
function doLoad()
{
        // only load if we aren't already doing so
        if(isLoading == false)
        {
                isLoading = true;
                if(image_mc) image_mc.removeMovieClip();
                createEmptyMovieClip("image_mc", 0);
                mcl.loadClip("http://www.some.com/image.jpg", image_mc)
        }
}
function onLoadInit(p_mc)
{
        isLoading = false;
        // if we should abort, go ahead and remove
        // the clip
        if(abortFurtherLoading)
        {
                abortFurtherLoading = false;
                removeTheClip();
        }
}
function doKill()
{
        // if we are loading...
        if(isLoading == true)
        {
                // ...wait till we're done
                abortFurtherLoading = true;
        }
        else
        {
                // ...otherwise, kill immediately
                removeTheClip();
        }
}
function removeTheClip()
{
        image_mc.removeMovieClip();
        delete image_mc;
}

init();


8 Replies to “MovieClipLoader Oddity in Flash Lite 2”

  1. Hi,
    I tried the above given actionscript by creating 2 buttons load and kill. Again it works properly on the emulator, but while testing on the mobile it gives the same error ‘unable to load data’. It would be very helpful if u could give more hints on this solution that u have got or i would appriciate a lot if i could get a proper fla file of the solution .
    waiting for the solution
    thanks
    veda

  2. The bottom line is do not removeMovieClip until you get an onLoadInit generated from MovieClipLoader. If the load is not done, and you abort it, you’ll get the error. Wait.

    I used a state variable above, but you could do something else if you wanted. Don’t interupt the load! Once started, it can’t be stopped.

  3. thanks for the fast reply
    My concern is not when to remove or the the movieClip.
    From past one mont i am trying to acess any form of data (jpeg, strings. variables or any). I tried all the provided flashlite2. 1.1 Cdks(FL 1.1- connect detect.fla, FL 1.1- import files.fla, FLNewsReader.fla ect..)and I also tried lots of other actionscript examples provided in the flash lite help.
    All of them work fine inthe emulator where i am testing on the desktop. But when the files are tranfered to the mobile and run, it works normally till the GPRS network connection is requested. After I say Yes to the reQuest it tries to download for some time and then’Unable to load data ‘ error appears.
    My GPRS connection to the MObile is normal & it has been checked and verified.
    So this has become a BIG Question of cocern for me. I am unable to identify the error and solve the problem. If any body out there have a SMALL solution for this or interested in discussing about the ERROR, please, i would like to know as soon as possible(immediately)

    The simple file contains the following actionscript:

    fscommand2(‘FullScreen’, true);

    if(image_mc) image_mc.removeMovieClip();

    createEmptyMovieClip(‘image_mc’, this.getNextHighestDepth());

    var mclListener:Object = new Object();

    mclListener.onLoadStart = function(image_mc:MovieClip) {
    trace(‘load started’);
    };

    mclListener.onLoadComplete = function(image_mc:MovieClip) {
    trace(‘load complete’);
    };

    mclListener.onLoadInit = function(image_mc:MovieClip) {
    trace (‘load initiated’);
    };

    var image_mcl:MovieClipLoader = new MovieClipLoader();

    image_mcl.addListener(mclListener);

    image_mcl.loadClip(‘http://www.helpexamples.com/flash/images/image1.jpg’, image_mc);

    If there is any error or i hav eto preset some publish setttings, please please give me some answers
    thanks
    veda

  4. Hi I am facing the following issue.
    I get

    FTPS035: A Call to loadMovie

    In my out put window

    Do you have any solutions for this.

Comments are closed.