Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > Simple Stuff (Newbies)

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-27-2011, 09:55 AM   #1
Ivon
Registered User
 
Join Date: May 2009
Posts: 25
Question The Preloader and the UILoader

Actionscript: 3.0

I'm probably doing something stupid (again); hence why I'm ask this here (newbie section).

Right now I have a separate Preloader (.fla) that has a UILoader component behind the movieclip that contains all the loading information (aka the percentage complete). This UILoader loads an external swf file, which is in the same folder as the preloader's swf.

I have NO errors coming out of this but when I preview I get just the movieclip and no activity.

If I comment out the section below "Test Section" and activate that (Test Section) the movieclip displays "42%"; no errors. So at least the movieclip stuff all works.

Apparently, the UILoader is failing to load the swf file but doesn't trigger any errors.

Quote:
UILoader Properties:
Instance Name: siteLoader

autoLoad: Checked
enabled: Checked
maintainAspectRatio: Checked
scaleContent: Unchecked [tends to screw up the movieclips]
source: Intentionally left blank as it should have been set in AS (siteLoader.load[...])
visible: Checked
Code:
stop();

/*Test Section
var percent:int = 42;
preloader_mc.percentText.text = percent + "%";
*/Test Section

import flash.net.URLRequest;
import flash.events.Event;

this.siteLoader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
this.siteLoader.addEventListener(Event.COMPLETE, completeHandler);

function progressHandler(e:ProgressEvent):void
{
	var siteLoaded:Number = e.target.bytesLoaded;
	var siteTotal:Number = e.target.bytesTotal;
	var percent:int = siteLoaded/siteTotal;

	preloader_mc.visible = true;
	
	siteLoader.load(new URLRequest("test.swf"));
	preloader_mc.percentText.text = percent + "%";
}

function completeHandler(e:Event):void
{
	preloader_mc.visible = false;
	this.siteLoader.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
	this.siteLoader.removeEventListener(Event.COMPLETE, completeHandler);
}
Ivon is offline   Reply With Quote
Old 06-27-2011, 01:46 PM   #2
marez32
Member
 
Join Date: May 2011
Posts: 52
Default

I know this is a stupid answer but, have you placed any stop() commands in the actions layer? this might be the reason it freezes at 42%? maybe you placed a stop() command in the UI Loader which prevents it from reaching the keyframe where it loads the other movieclip from an external swf file.

Check if you placed a swf file of the movieclip you wish to load in the same folder.
marez32 is offline   Reply With Quote
Old 06-27-2011, 02:08 PM   #3
Ivon
Registered User
 
Join Date: May 2009
Posts: 25
Default

Quote:
Originally Posted by marez32 View Post
I know this is a stupid answer but, have you placed any stop() commands in the actions layer? this might be the reason it freezes at 42%? maybe you placed a stop() command in the UI Loader which prevents it from reaching the keyframe where it loads the other movieclip from an external swf file.

Check if you placed a swf file of the movieclip you wish to load in the same folder.
only 'stop();' so far is the one you see in the posted code; love me some 'gotoAndPlay/Stop();'.

As for the 42% that was a test to see if the "path" to the text box was correct and to make sure I got the formatting right...glad I did that because the "%" was out of the text field; had to resize it.

All of the [.fla]s are located in the same folder. As are their [.swf]s.

Perhaps...the actual FLA should be posted too...

EDIT:
won't bother posting the 'test.swf' as a quick one could be made with just some text.
Attached Files
File Type: zip preloader_test.zip (434.2 KB, 76 views)

Last edited by Ivon; 06-27-2011 at 02:09 PM. Reason: Other Thoughts...
Ivon is offline   Reply With Quote
Old 06-28-2011, 02:06 AM   #4
marez32
Member
 
Join Date: May 2011
Posts: 52
Default

I cant seem to open the file in CS4............ ................ ............ are you using cs5?

Coz i don't have cs5 yet
marez32 is offline   Reply With Quote
Old 06-28-2011, 03:57 AM   #5
Ivon
Registered User
 
Join Date: May 2009
Posts: 25
Default

Quote:
Originally Posted by marez32 View Post
I cant seem to open the file in CS4............ ................ ............ are you using cs5?

Coz i don't have cs5 yet
Yes, CS5
Ivon is offline   Reply With Quote
Old 06-28-2011, 10:14 AM   #6
marez32
Member
 
Join Date: May 2011
Posts: 52
Default

I suggest you to save the file as a CS4 file by Quickly pressing shift , then control + s.

You can select cs4 and then I can fix it for you.
If you attach the xml file I can help you even more.

But I suggest you to pm me so I can fix it more faster.
marez32 is offline   Reply With Quote
Old 06-28-2011, 10:27 AM   #7
Ivon
Registered User
 
Join Date: May 2009
Posts: 25
Default

Not entirely sure what you mean by "attach the XML".

But here's the CS4 version...though it did lose the TLF text.
Attached Files
File Type: zip preloader_test-cs4.zip (280.7 KB, 62 views)
Ivon is offline   Reply With Quote
Old 06-28-2011, 10:49 AM   #8
marez32
Member
 
Join Date: May 2011
Posts: 52
Default

Okay................ I think I know why you can't see the test.swf file! You haven't told the actionscript 3 where you want it placed!!!

Right now your test.swf is loading in lost 'space' outside the stage!!!

you need to type

test.swf.x=10
test.swf.y=20

I'm coding now and it will be here in a moment... .... ...

edit:
no that doesn't seem to be the problem.....

how do you make the timer start? it's stuck on 42%
would you be able to attach the full code which was hundreds of lines long?

in the meantime here's a video on youtube someone shows how to use UI Loaders to load external images but not swf files.
h t t p : / / w w w . y o u t u b e . c o m / w a t c h ? v = i Q N 7 n 8 X u I V I

Last edited by marez32; 06-28-2011 at 11:29 AM.
marez32 is offline   Reply With Quote
Old 06-28-2011, 12:27 PM   #9
Ivon
Registered User
 
Join Date: May 2009
Posts: 25
Default

I don't think I need to set x,y-coords. The lesson plan I based this preloader off doesn't use it.

Here's the lesson plan (converted to cs4)

(www of course)
mediafire.com/file/d8194j4zcrgb64a/lesson6-cs4.zip

EDIT:

lol, AS hates me...I modified the code to the below. Changed the swf to be loaded to one DIRECTLY from the AS 3 Lesson Book...and it works...something is wrong with [i]my[/y] swf... :|


Code:
stop();
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;

var siteRequest:URLRequest = new URLRequest("lesson12_complete.swf");

siteLoader.addEventListener(Event.COMPLETE, completeHandler);
siteLoader.addEventListener(ProgressEvent.PROGRESS, progressHandler);

siteLoader.load(siteRequest); 

function progressHandler(e:ProgressEvent):void
{
	var siteLoaded:Number = e.target.bytesLoaded;
	var siteTotal:Number = e.target.bytesTotal;
	var percent:int = siteLoaded / siteTotal;
	preloader_mc.visible = true;

	preloader_mc.percentText.text = percent + "%";
}

function completeHandler(e:Event):void
{
	preloader_mc.visible = false;
}

Last edited by Ivon; 06-29-2011 at 01:00 PM. Reason: AS3 HATES ME!
Ivon is offline   Reply With Quote
Old 07-01-2011, 06:26 AM   #10
Mazoonist
Site Contributor
 
Mazoonist's Avatar
 
Join Date: Jun 2006
Posts: 3,160
Send a message via AIM to Mazoonist
Default

Your previous code had the command to load the file INSIDE the progress handler. That was wrong because you only need to issue the command to load the file ONCE, and do it OUTSIDE of any functions.

Your new code has corrected this and placed that line outside the function.

Also, if you want to see the loading progress when you test your movie, pull down the View menu on the running swf and choose "Simulate Download." You may also need to adjust "Download Settings" on the same menu for the desired download speed.
__________________
My Tutorials * My Website
Mazoonist is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:29 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.