Results 1 to 4 of 4
Thread: Loading swf's errors
-
May 2nd, 2009, 02:11 PM #165Registered User
postsLoading 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()
-
May 2nd, 2009, 02:37 PM #21,596Holosuite User
postsYou 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().Code:loadContent_mc.addChild(loadEvent.currentTarget.content);
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
-
May 2nd, 2009, 03:07 PM #365Registered User
posts
-
May 2nd, 2009, 03:36 PM #41,596Holosuite User
postsIf 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

Reply With Quote


Bookmarks