Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-17-2008, 10:13 PM   PM User | #1
aWishResigned
New Coder

 
Join Date: Nov 2007
Posts: 72
Thanks: 0
Thanked 1 Time in 1 Post
aWishResigned is an unknown quantity at this point
Preloading Question

This is something that's bugged me for years and I've just never gotten around to addressing it.

Say I've got a movie with a bitmap (that's has a relatively large filesize) for a background that starts on frame 2 and a preloader (which is entirely vector and therefore not that big of a file) that is on frame 1. Even though the bitmap hasn't loaded yet, the movie still stalls until it has loaded, making the preloader seemingly start at say 60 or 70 percent.

Can anyone here explain to me what's going on and what I could maybe do to fix it?
aWishResigned is offline   Reply With Quote
Old 04-17-2008, 10:22 PM   PM User | #2
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
It depends on how your preloader is setup. Does it load by frames or by filesize? Do you have some code to show?
gnomeontherun is offline   Reply With Quote
Old 04-17-2008, 10:30 PM   PM User | #3
aWishResigned
New Coder

 
Join Date: Nov 2007
Posts: 72
Thanks: 0
Thanked 1 Time in 1 Post
aWishResigned is an unknown quantity at this point
Sure. It's a simple onEnterFrame that cycles and checks the loaded bytes against the total bytes. Here's the code:

Code:
this.onEnterFrame = function() {
if (picture_one_mc._loaded && picture_two_mc._loaded && picture_three_mc._loaded) {
	delete this.onEnterFrame;
			
	var pre_out:Tween = new Tween(preload_mc, '_alpha', Regular.easeOut, 100, 0, 5, false);
	pre_out.onMotionFinished = function() {
		_root.play();
	}
			
} else {
	var bl:Number = (picture_one_mc.picture_mc.getBytesLoaded() + picture_two_mc.picture_mc.getBytesLoaded() + picture_three_mc.picture_mc.getBytesLoaded() + _root.getBytesLoaded());
	var bt:Number = (picture_one_mc.picture_mc.getBytesTotal() + picture_two_mc.picture_mc.getBytesTotal() + picture_three_mc.picture_mc.getBytesTotal() + _root.getBytesTotal());
	preload_mc.bar_mc._width = Math.floor((bl / bt) * 305);
}
}
I'd like to point out that the picture_one_mc._loaded stuff is based on individual images being called to load. They're just booleans that help me to know if I should even worry about the preloader at all.

Last edited by aWishResigned; 04-17-2008 at 11:05 PM..
aWishResigned is offline   Reply With Quote
Old 04-18-2008, 12:38 AM   PM User | #4
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
I think your math is more complicated than it needs to be.

Assuming it is on the first frame, root timeline, why not try

Code:
 else {
	var bl:Number = Math.round(this.getBytesLoaded());
	var bt:Number = Math.round(this.getBytesTotal());
	preload_mc.bar_mc._width = Math.round(bl / bt * 100 * 305);
}
This would just get the size of the movie, and not have to pull the individual elements.
gnomeontherun is offline   Reply With Quote
Old 04-18-2008, 02:03 PM   PM User | #5
aWishResigned
New Coder

 
Join Date: Nov 2007
Posts: 72
Thanks: 0
Thanked 1 Time in 1 Post
aWishResigned is an unknown quantity at this point
You're exactly right and, if it were any other project, I would agree wholeheartedly. This particular project involves cues within a movie which mean that they have to be loaded before the movie even starts.

This is just a generic code block to illustrate my point better:
Code:
stop();
this.onEnterFrame = function() {
  var bl:Number = _root.getBytesLoaded();
  var bt:Number = _root.getBytesTotal();
  
  if (bl >= bt) {
    delete this.onEnterFrame;
    _root.play();
  } else {
    preload_mc.bar_mc._width = Math.round((bl / bt) * 300);
  }
};
aWishResigned is offline   Reply With Quote
Old 04-18-2008, 03:36 PM   PM User | #6
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
Ok, cues within the Flash video? The term movie is ambiguous
gnomeontherun is offline   Reply With Quote
Old 04-18-2008, 03:41 PM   PM User | #7
aWishResigned
New Coder

 
Join Date: Nov 2007
Posts: 72
Thanks: 0
Thanked 1 Time in 1 Post
aWishResigned is an unknown quantity at this point
Yes, cues within a flash video but, what I meant was that the fact that there was a video in the movie is not important. All I'm looking for is to know how flash will load a movie. If, when there is a large filesize in frame 2, why can't I get a preloader to start eariler in frame 1. It will usually just be a white screen and then appear when the preloader is about halfway complete.
aWishResigned is offline   Reply With Quote
Old 04-18-2008, 08:34 PM   PM User | #8
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
I take it you've tried the simplified version of the code? Is the file in frame 2 being loaded from an external source or as part of the swf?

Do you have the page url to show? I'm curious to see this, maybe I'll understand better. I'm not sure I can answer this, but I still don't know why you need to add the three movieclip sizes together, and then use the entire filesize. It seems (in my understanding) that you are actually adding up the total twice.
gnomeontherun is offline   Reply With Quote
Old 04-18-2008, 09:55 PM   PM User | #9
aWishResigned
New Coder

 
Join Date: Nov 2007
Posts: 72
Thanks: 0
Thanked 1 Time in 1 Post
aWishResigned is an unknown quantity at this point
Quote:
Originally Posted by jeremywilken View Post
I take it you've tried the simplified version of the code?
By the simplified version, do you mean the jumping back and forth between two frames as opposed to using an onEnterFrame? If so, then yes, I have and I've moved on to this.

Quote:
Originally Posted by jeremywilken View Post
Do you have the page url to show? I'm curious to see this, maybe I'll understand better. I'm not sure I can answer this, but I still don't know why you need to add the three movieclip sizes together, and then use the entire filesize. It seems (in my understanding) that you are actually adding up the total twice.
As of right now, no I don't. The fact that I had other images being loaded with the root is not the issue here. Those other images are being loaded based off of an xml file so that the client can change the pictures that will show on top of the *.flv file. (Think of a television news anchor with a picture about the news story to the side of him. The client, who is speaking in the film wants to have pictures that he's uploaded to show as he's talking.) So, in order for the pictures to be guaranteed to show up at the right time and actually be there, I made the preloader check to see if they're all loaded.

The question I have is that, if you just had a normal flash file with no outside resources being loaded in (the only elements in the *.swf are the ones that were in the library at compile time), why, when you only have a small vector progress bar, will it not display right off and show the progress of the whole movie being loaded? As it stands right now, if I use a bitmap for a background (or have some large file in the next frame), the preloader will only appear once the *.swf file has already loaded about 40-60%.

What about the procedures that Flash uses to download *.swf files do I need to know or know better to be able to make the preloader show at 1%?
aWishResigned is offline   Reply With Quote
Old 04-18-2008, 10:29 PM   PM User | #10
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
By simplified I meant the code I posted that reduced the math.

Can you post the FLA? Just remove the big images and put some kind of placeholder so I can see the structure. It doesn't make sense, which is why I want to see the structure of the file.
gnomeontherun is offline   Reply With Quote
Old 04-18-2008, 10:46 PM   PM User | #11
aWishResigned
New Coder

 
Join Date: Nov 2007
Posts: 72
Thanks: 0
Thanked 1 Time in 1 Post
aWishResigned is an unknown quantity at this point
Since I'm talking about all *.fla files in general, I made a quick and dirty one for you. Run it, drop the simulation speed down to 56k and simulate the download. The preloader doesn't show until about 25-26%.

Can't seem to upload it here so the url is: http://www.globalnetdesigns.com/stephen/test.zip
aWishResigned is offline   Reply With Quote
Old 04-18-2008, 10:57 PM   PM User | #12
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
Ok I get your question.

http://www.senocular.com/flash/tutorials/faq/

If your file isn't all that large, then the swf might have a larger percentage of the file loaded before getting rendered on the page. So by the time enough of the SWF is loaded to play the first frame, it might have already gotten more than enough loaded to set your bar above 0%.
gnomeontherun is offline   Reply With Quote
Old 04-21-2008, 06:14 PM   PM User | #13
aWishResigned
New Coder

 
Join Date: Nov 2007
Posts: 72
Thanks: 0
Thanked 1 Time in 1 Post
aWishResigned is an unknown quantity at this point
Thanks. Got what I needed.
aWishResigned is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:45 PM.


Advertisement
Log in to turn off these ads.