-
Hi all
is there anyway to Examine on pictures of jpg type
when loading if so which script
I should use ?
is it something like
i = "mypic.jpg";
if(i.getBytesLoaded() == i.getBytesTotal()){
myClip.loadMovie(i);
}else {
display = "please wait picture is loading";
}
please help soon
-
Senior Member
you want a preloader for you picture?
if your picture is externally loaded to a movieclip, just preload the clip;
"mc" is the instance name of the clip the pic is loaded to.
this code goes on the timeline, frame 1
mc.loadMovie("your_image.jpg");
this code goes directly on the movieclip;
onClipEvent (load) {
this._alpha = 0;
}
onClipEvent (enterFrame) {
L = this.getBytesLoaded() / 1024;
T = this.getBytesTotal() / 1024;
P = L / T * 100;
if (P == 100) {
this._alpha = 100;
}
}
If you need further assistance, just ask.
-
nice code EQFlash. Even i would have said the same thing.
but we should avoid using events like "onClipEvent (enterFrame)" for it keeps playing even when task has been achived.
-
Senior Member
-
Flash MX code:
movieclip.prototype.load = function(obj,img,posx,posy) {
obj.loadMovie(img);
obj._x = posx;
obj._y = posy;
loaded = obj.getBytesLoaded();
total = obj.getBytesTotal();
}
call it like this:
load(placeholder_MC, "picture.jpg", 100,100);
That«s it...
just take out the values from loaded and total to show the loading-progress...
have fun,
Manuel
-
Trooper, your code looks very professional man.
-
troopers code is exactly what i have been searching for and it works perfectly.
I have one question though, i am having trouble grabbing the variable from loaded...this is the code i inserted into the main chunk of code...
info.text = loaded + "% completed";
where text is my dynamic text box
can anyone help me with the load progress?
-
try this one BOC,
info.text = movieclip.loaded + "% completed";
-
thanks for the help Sid, that line makes more sense but im still messing something up.
this is the code in my first frame:
movieclip.prototype.load = function(obj,img,posx,posy) {
obj.loadMovie(img);
obj._x = posx;
obj._y = posy;
loaded = obj.getBytesLoaded();
total = obj.getBytesTotal();
info.text = loadtext.loaded + "% complete";
}
load(dropzone, "pic.jpg", 100,100);
the image still appears in dropzone, but when i test it on a low bandwidth connection, i dont get a load sequence. so i dont think it works right.
i put my dynamic text box, instance name 'text', in a movie clip instance named 'loadtext'. that movie is 100 frames long. i know im missing something...
-
Senior Member
Originally posted by Trooper977
Flash MX code:
movieclip.prototype.load = function(obj,img,posx,posy) {
obj.loadMovie(img);
obj._x = posx;
obj._y = posy;
loaded = obj.getBytesLoaded();
total = obj.getBytesTotal();
}
call it like this:
load(placeholder_MC, "picture.jpg", 100,100);
That«s it...
just take out the values from loaded and total to show the loading-progress...
have fun,
Manuel
Does that mess with the loading of ANY MC or just the movieclip in question? I mean, I sould use the MovieClip.prototype.load = ... and then I can use to any instance or I use myMC.prototype.load? I guess it`s the earlier, but I am never sure
Thanks,
Leo
-
it doesnt work when i replace movieclip with dropzone (which is the name of the movie clip i am loading my .jpgs into) so i guess thats the answer.
-
Hi,
movieclip.prototype.functionname = function (.....)
is a standard code.
movieclip.prototype is a once set multiusuable code.
Don«t change movieclip into some other clipname or so.
just use:
yourmovie.load (......);
That«s all.
Hope your pic-loading works well!
Manuel
-
i dono....
i'm sorry guys but i can't seem to get this to work... the
code looks great, and the image loads fine but i can't get
the proper file size of the image being loaded... is there
something i'm doing wrong?... (i've been fighting with
this sort of code for a week now)
__________________________________________________ ______
movieclip.prototype.load = function(obj,img,posx,posy) {
obj.loadMovie(img);
obj._x = posx;
obj._y = posy;
loaded = obj.getBytesLoaded();
total = obj.getBytesTotal();
percloaded = total / 1024;
}
__________________________________________________ ______
i have this attached to a button:
__________________________________________________ ______
on (release) {
load(Loader_MC, "1.jpg", 0,0);
}
__________________________________________________ ______
it's the same since i've started trying when i hit the
button my dynamic text field gives me "0.00390625" then if
i hit it again it removes the image and gives
me "22.2998046875"
i'm at a loss here.. any ideas?!..
thanks a bunch!.. ^_^ !!
-
newbie
Your code:
Code:
percloaded = total / 1024;
change it to
Code:
percloaded = loaded / total;
PROBLEM IS THIS:
When you load a jpg into a "holder" instance that you created (ie not created at runtime), you have a obj.getBytesLoaded() and obj.getBytesTotal() of 4 bytes!!
Note: THIS WON'T HAPPEN IF YOU ARE LOADING FROM DISK because it loads instantly, but if you put it on the net, you are going to have problems.
This explains why your text field initially returned 0.00390625 (4 bytes/1024).
The second time you update the text field, it returned 22.2998046875 (22835 bytes/1024). The size of you jpg is actually 22835 bytes, not 4 bytes. Because you asked the obj the loaded and total bytes almost instantly after your loadMovie command, the initial return of both getBytesLoaded() and getBytesTotal() will be 4 bytes.
weird...?
SOLUTION:
Make your placeholder at runtime:
Code:
//create the empty clip:
this.createEmptyMovieClip("holder",1);
//load a picture, (the random(999) is to prevent it from caching, just so you can test it more than once)
holder.loadMovie("http://yourdomain.com/pic.jpg?" + random(999));
//this traces the bytes loaded and total:
this.onEnterFrame=function(){
trace(this.holder.getBytesLoaded());
trace(this.holder.getBytesTotal());
}
If you don't believe me, try this:
Code:
//make your own "holder"
//load a picture to "holder", (the random(999) is to prevent it from caching, just so you can test it more than once)
holder.loadMovie("http://yourdomain.com/pic.jpg?" + random(999));
//this traces the bytes loaded and total:
this.onEnterFrame=function(){
trace(this.holder.getBytesLoaded());
trace(this.holder.getBytesTotal());
}
The first two values that you see in the output window is:
4
4
(even when the picture doesn't exist, try http://yahoo.com/sdfasfasd.jpg)
Hope I didn't confuse you
[Edited by McFalski on 08-15-2002 at 10:21 AM]
-
Hi there,
it is as McFalski says.
just one thing to add:
To recieve the percentage of loading-progress u must use:
percent = loaded*100/total;
Gives you a number from 0 up to 100.
Just use: yourmovieclip.output.text=percent+" %";
That«s it.
Manuel
-
thanks!
thank you very much that helped with loading the image
however i have a bunch i want to load and it doesn't
continue to work after i load the first one...
http://www.smythe.nbcc.nb.ca/class99...misc/test2.fla
this is my test file.. it's ugly but should be working
just fine... if you'd be so kind as to take a look..
thanks a lot.. this one has really got me stumped!
@_*;;;
-
ok now im totally and completely lost.
can i get a definitive answer to how to preload a .jpg?
i am new to actionscript and im running around in circles at everyones different oppinion as to how to do this.
all i want to do is to preload a .jpg and show the bytes loading progressively in a dynamic text box. i can get the .jpg to load, but i cant get my dynamic text box to show the bytes loading.
is there just a canned answer to this?
explain it to me as if i were a 2 year old ; D
-
Originally posted by bucket of chicken
ok now im totally and completely lost.
can i get a definitive answer to how to preload a .jpg?
i am new to actionscript and im running around in circles at everyones different oppinion as to how to do this.
all i want to do is to preload a .jpg and show the bytes loading progressively in a dynamic text box. i can get the .jpg to load, but i cant get my dynamic text box to show the bytes loading.
is there just a canned answer to this?
explain it to me as if i were a 2 year old ; D
Take a look at this site. Go to the pictures page and see if it is something like what you want with the preloader.
http://www.caprockoutfitters.com/flash/CAP.html
-
newbie
-
newbie
Another really simple way of making a preloader is to check the width or height of the loaded image. (no bytesLoaded or bytesTotal involved)
The placeHolder.width will be > 0 only after the image is loaded. Simple way to avoid all that byte stuff.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|