Web Design Forums

Graphics Articles & Tutorials

Learn how to create beautiful and functional graphics for your next web design project.

'Percentage Loaded' Preloader in Flash MX



Site of the Month Voting - Now Open. CAST YOUR VOTE NOW!

Reply
 
LinkBack Thread Tools
Old February 22 '04, 10:09 AM (#1)
AndyMills is offline
New Member!
 
AndyMills's Avatar
 
Join Date: February 2004
Location: United Kingdom
Posts: 6
AndyMills
'Percentage Loaded' Preloader in Flash MX

Ever wondered how to make one of those percentage loaded counters on a Flash Movie? The one's that tell you what percent of the movie has loaded? Here's how:
[list=1][*]Add a blank keyframe at the beginning of your movie and name it Preload.[*]Name the frame which holds the first frame of your movie MovieStart.[*]Add a text field to the part of the page where you want your counter.[*]Set the properties of the text field to be a Dynamic Text Field[*]Set the variable field in the text box to say PercentLoaded.[*]Add this code to the keyframe containing your text field:
MovieSize = _root.getBytesTotal ();
LoadedSize = _root.getBytesLoaded();
PercentLoaded = LoadedSize / MovieSize * 100
if (PercentLoaded < 1) {
gotoAndPlay("Preload");
}
else {
gotoAndPlay("MovieStart");[/list=1]

Lines 5 and 8 of the code have tab spaces before them, but I couldnt do that in the thread...sorry.

Last edited by AndyMills; February 22 '04 at 01:20 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 22 '04, 12:38 PM (#2)
smoseley is online now
WDF Moderator
 
smoseley's Avatar
 
Join Date: March 2003
Location: Miami, FL
Posts: 8,719
smoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud ofsmoseley has much to be proud of
I would change the if statement to this, just to be more exact.
Code:
if (_root.getBytesLoaded() < _root.getBytesTotal()) {
    gotoAndPlay("Preload");
} else {
    gotoAndPlay("MovieStart");
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old April 9 '04, 08:56 PM (#3)
m.mckernan is offline
WDF Regular
 
m.mckernan's Avatar
 
Join Date: August 2003
Location: Melbourne, Australia
Posts: 162
m.mckernan is on a distinguished road
What changes to this would I need to do so it would fetch external files into the IE cache?

IE. To have it preload jpg and gifs to make a site run faster.

EDIT: And to have it load external flash files that will run elsewhere on the site.

Last edited by m.mckernan; April 9 '04 at 08:57 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 28 '04, 05:33 PM (#4)
sopiaz57 is offline
WDF Member
 
sopiaz57's Avatar
 
Join Date: September 2003
Posts: 41
sopiaz57
This isnt really working well for me, I am using a new version of flash, mx 2004.

I basically did exactly what you posted, however when i go to test the movie using a 14.4 bandwidth setting, all i see real fast is a large decimal number where my text field was.

I embedded a 15 MB movie into the movie frame.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 20 '05, 04:29 AM (#5)
themayanlion is offline
WDF Member
 
themayanlion's Avatar
 
Join Date: March 2005
Posts: 40
themayanlion is on a distinguished road
the preloader i use, which seems to work in everything i do is this. all that's different is that percentLoaded is my variable name, but i mean you can change that.

in the first frame, add this:

Code:
stop();
myInterval = setInterval(preloader, 10);
function preloader(){
	if(getBytesLoaded()>=getBytesTotal()){
		play();
		clearInterval(myInterval);
		}
	percentLoaded = Math.ceil ((getBytesLoaded()/getBytesTotal()) * 100);
	preloader_text.text = percentLoaded + "%";
}
if you want a loading bar as well, just create one and call it loader (only on the first frame), then add (in blue)

Code:
stop();
myInterval = setInterval(preloader, 10);
function preloader(){
	if(getBytesLoaded()>=getBytesTotal()){
		play();
		clearInterval(myInterval);
		}
	percentLoaded = Math.ceil ((getBytesLoaded()/getBytesTotal()) * 100);
	preloader_text.text = percentLoaded + "%";
        loader._xscale = (getBytesLoaded()/getBytesTotal())*100;
}
you can of course, modify that to _alpha, _yscale, whatever you want.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  Web Design Forums » Web Design Help » Articles & Tutorials » Graphics Articles & Tutorials

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On


 
User Infomation
Your Avatar

Site Of The Month
Nominate Your Site Now!

Advertisement
WolfCMS.org

Latest Articles
- by RickM
- by bfsog

Advertisement

Partner Links



All times are GMT -4. The time now is 01:49 PM.


WebDesignForums.net is Copyright © 2010 RikeMedia.

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164