The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 4 of 4

Thread: Loading swf's errors

  1. #1

    Loading swf's errors

    Im making a main page that will load different content into one loader. I have the loading URLRequest calling a variable for the link and then on a certain button click it will change the swf to be loading. The problem is this:
    This code is being called in a movieclip inside the main timeline called "loaderHolder"

    //I have all the variables initiated above these functions
    function startLoad()
    {
    trace("Started");
    mRequest = new URLRequest(MovieClip(root).loadContent);
    trace(MovieClip(root).loadContent);
    mLoader.load(mRequest);
    }// end function

    function onProgressHandler(mProgress:ProgressEvent)
    {
    var percent:Number = Math.round((mProgress.bytesLoaded / mProgress.bytesTotal)*100);
    load_txt.text = percent + "%";
    load_txt.setTextFormat(LF_txt);
    }// end function

    function onCompleteHandler(loadEvent:Event)
    {
    loadContent_mc.addChild(loadEvent.currentTarget.content);
    removeChildAt(2);
    removeChildAt(1);
    }// end function


    This is on the main timeline. These functions trigger a tween that will drop then comeback (yoyo) with new content to load.


    //Tween/Start Loader
    // Working to get tween to run then pop back with new content
    var loadLoaderTween:Tween = new Tween(loaderHolder, "y", Strong.easeInOut, 1191.0, stage.stageHeight/2, 2, true);
    loadLoaderTween.addEventListener(TweenEvent.MOTION_STOP, startLoading);
    //This initiates the very first load
    function startLoading(e:TweenEvent) {
    this.loaderHolder.startLoad();
    }

    //Unload Current - Triggers on a button click
    function unLoad() {
    loadLoaderTween = new Tween(loaderHolder, "y", Strong.easeInOut, loaderHolder.y, 1191.0, 2, true);
    loadLoaderTween.addEventListener(TweenEvent.MOTION_STOP, startNewLoad);
    this.loaderHolder.mLoader.close();
    }
    function startNewLoad(e:TweenEvent) {
    loadLoaderTween.removeEventListener(TweenEvent.MOTION_STOP, startNewLoad);
    loadLoaderTween.yoyo();
    trace("Works");
    loadContent = "/flash/test2.swf";
    this.loaderHolder.startLoad();
    }


    I get these errors:
    Code:
    Error: Error #2029: This URLStream object does not have a stream opened.
    	at flash.display::Loader/close()
    	at csteelmedia_fla::MainTimeline/unLoad()
    	at csteelmedia_fla::btn_web_8/clicked()
    Code:
    //This one happens at this point: mLoader.load(mRequest);
    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    	at flash.display::Loader/_load()
    	at flash.display::Loader/load()
    	at csteelmedia_fla::mc_loaderHolder_1/startLoad()
    	at csteelmedia_fla::MainTimeline/startNewLoad()
    	at flash.events::EventDispatcher/dispatchEventFunction()
    	at flash.events::EventDispatcher/dispatchEvent()
    	at fl.transitions::Tween/stop()
    	at fl.transitions::Tween/set time()
    	at fl.transitions::Tween/nextFrame()
    	at fl.transitions::Tween/onEnterFrame()

  2. #2
    1,596
    posts
    Holosuite User
    Code:
    loadContent_mc.addChild(loadEvent.currentTarget.content);
    You shouldn't reparent Loader's content. If it's a picture, it'll became a Bitmap, you can than grab it's bitmapdata and use it elsewhere. If it's an SWF, you can then reuse loaderInfo.bytes in combination with Loader#loadBytes().
    This is also considered a good practice because technically you can reparent loader's content, but once you do so, you cannot call Loader#unload() or load other content with it. It's also easier to add the entire Loader to the display list than try to separate it from it's content. I'd better stick to that latter idea as it less troublesome.
    Besides, your functions are missing return type.
    Last edited by wvxvw; May 2nd, 2009 at 02:39 PM.

    I support FlashDevelop (the .NET open source editor for Flash and web developers)
    couchsurfing if you need it

  3. #3
    Quote Originally Posted by wvxvw View Post
    Code:
    loadContent_mc.addChild(loadEvent.currentTarget.content);
    You shouldn't reparent Loader's content. If it's a picture, it'll became a Bitmap, you can than grab it's bitmapdata and use it elsewhere. If it's an SWF, you can then reuse loaderInfo.bytes in combination with Loader#loadBytes().
    This is also considered a good practice because technically you can reparent loader's content, but once you do so, you cannot call Loader#unload() or load other content with it. It's also easier to add the entire Loader to the display list than try to separate it from it's content. I'd better stick to that latter idea as it less troublesome.
    Besides, your functions are missing return type.
    OK so I will give your code above a try. What should my return types be. I am a ok flash coder and still trying to learn but I never know when to use return;

  4. #4
    1,596
    posts
    Holosuite User
    If function doesn't return anything you type it to "void". Eg.:
    Code:
    function f():void {};

    I support FlashDevelop (the .NET open source editor for Flash and web developers)
    couchsurfing if you need it

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012