Ultrashock Forums > Flash > ActionScript
• preloading dynamically loaded jpgs?

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
preloading dynamically loaded jpgs?
Old 2003-03-04

Hi,
i just want to use my preloader for preloading dynamically loaded jpgs, but i canīt get it running!

There are severall movieclips in my scene, for exsample: One for buttons, one for a preloader and one as a target for the jpgs. If you press a button the according jpg is loading in the target mc (loadMovie).
So far everything works fine, but...

...now i want to check the loading status of the jpg using my preloader (nested in another movieclip) with a bar and percentage-display and so on.

This step did not work and i donīt know why. After spending hours of unsuccessfully searching in the web i still hope there will be someone who knows a solution for this matter!

Plz help me!
...also feel free to contact me via icq: 41057045
Thanks ahead!
postbit arrow 3 comments | 258 views postbit arrow Reply: with Quote   
Registered User
ohara is offline
seperator
Posts: 31
2003-01-25
Age: 35
seperator

Ultrashock Member Comments:
Brad-J Brad-J is offline Brad-J lives in United States 2003-03-04 #2 Old  
ohara,
put something to this effect on the movie clip that is for your bar that is going to scale:

Code:
onClipEvent (enterFrame) {
  this._xscale = (_root.photoHolder.getBytesLoaded()/_root.photoHolder.getBytesTotal())*100;
	if (this._xscale == 100) {
		this._visible = false;
	} else {
		this._visible = true;
	}
}
where photoholder is the name of the movie clip that is holding your jpgs. that should get you started.

-brad
Reply With Quote  
ohara ohara is offline 2003-03-04 #3 Old  
thank u for the quick answer...
...but i have to explain my problem in more detail!

My preloader works fine when i use it in the first frame of a movieclip.
The code for it is:

perc = Math.round((_root.getBytesLoaded()/_root.getBytesTotal())*100);
xperc = perc/100;
barlength = 120;
if ((perc == 100) and (bar._width == barlength)) {
gotoAndPlay(4);
//at this frame the bar fades out and _root is going to the next frame
} else {
nperc = perc+"%";
bar._width = barlength*xperc;
bar._x = -60+(bar._width/2);
}

Because the bar and another small effekt (which is playing while preloading) are allready loaded for the root-scene, i wanted to use them for preloading the jpgs too. I duplicated and placed them in another movieclip with the path of the imageholder-MC in the actionscript (in this case (_root.imageholder.getBytesLoaded()/_root.imageholder.getBytesTotal()) )
You can see the result on: www.digitailor.de/test (in the supmenue 3DArtwork/highres)
At the first time i thought that it did not work, because the new loaded jpg resets all settings of the imageholder-Mc and consequently my path would be wrong. Therefor i tried to use a variable path like this:
for (i = 1; i<10, i++){
(_parent["myImageName"+i+".jpg"].getBytesLoaded()/_parent["myImageName"+i+".jpg"].getBytesTotal())......

Because i am not very familiar with programming and new to flash i tried different spellings without success. Do you know if itīs generally possible to preload a jpg from within another MC?
Reply With Quote  
ohara ohara is offline 2003-03-05 #4 Old  
Ok, ignore my last post and the theory of a path-problem! I used the onClipEvent (enterFrame) handler and it works! Thanks a lot to BradJ for that hint!

For all who want to use a certain bar for preloading dynamically loaded jpgs or movies, this may will help:

1. Use the onClipEvent(enterFrame) for that matter. For more information about that look at: http://news.flashguru.co.uk/?aid=000044


2. Exsample Code:
//////////////////////////////////////////////////////////////////////////////////
onClipEvent (enterFrame) {
perc = Math.round((_root.MCimageholder.getBytesLoaded()/_root.MCimageholder.getBytesTotal())*100);
xperc = perc/100;
barlength = 120;
if ((perc == 100) and (this._width == barlength)) {
this._visible = false;
} else {
nperc = perc+"%";
this._visible = true;
this._width = barlength*xperc;
this._x = -60+(this._width/2);
}
}
//////////////////////////////////////////////////////////////////////////////////
happyPreloading,

ohara
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: