?
Solved

Preload dynamically loaded jpgs?

Posted on 2003-03-23
16
Medium Priority
?
282 Views
Last Modified: 2010-04-03
Hi all,
I am working on a project that dynamically loads jpg images whose names are called from an external text file. I have it working well using the loadMovie() function, the only thing is that I would like to preload these images all at once and display a simple progress bar, then proceed to the first frame of my main scene.

I have no trouble with standard preloading practices, but this is the first time I've needed to preload dynamic elements. I found a page with some info on the subject at http://news.flashguru.co.uk/?aid=000044 , but I am a little(!) confused by it.

Here is the relevant portion of the code I have written so far:

****begin code

var whichtut
loadVarsText = new loadVars();
loadVarsText.load(whichtut + ".txt");
loadVarsText.onLoad = function(success) {
     if (success) {
          titlebox.html = true;
          titlebox.htmlText = this.title;
          instructions.html = true;
          instructions.htmlText = this.start;
          statusbox.html = true;
          statusbox.htmlText = "Step <b>"+[_currentframe-1]+"</b> of <b>"+this.numsteps+"</b>";
     } else {
          trace("error - text data not loaded");
     }

     //convert number of steps from text file to an integer
     numsteps=parseInt(this.numsteps);

     //if current step == total number of steps, disable "next" button
     if (numsteps == _currentframe-1) {
          nextbutton.enabled = false;
     } else{
          nextbutton.enabled = true;
     }    
_root.createEmptyMovieClip("graphic", 10);
graphic._x = 67;
graphic._y = 50;
thisgraphic = this.pic00;
loadMovie(thisgraphic, "graphic");

stop();

};
stop();

end code*****

As you can see, what I want to do is to preload the images that are loaded into the movieclip "graphic".

Please post any insight you might have into this issue.
Thanks in advance,
Kris M
0
Comment
Question by:kris_mcl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
16 Comments
 
LVL 6

Expert Comment

by:henryww
ID: 8191448
so u want to preload all the images before user can use the next button??

or one by one and user can get to see as much as loaded ... ???
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 8191759
you're making something simple into something quite complicated..
the images may as well be embedded in the movie..
however seeing you've taken the route you have if you
import the images to the library and then drag and drop them around and well outside the stage in the first few
frames where your preloader is..the player is forced to
load them along with the other content.
if they are spread over several frames you can track the
advancing player in a preloader..frame by frame..to give
you the progress graph.

Z
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kris_mcl
ID: 8192803
Thanks for the comments, guys/gals.

This may not have been clear in my first post, but the reason that the images cannot be embedded is that this is an instructional tutorial that I am building. It will be an empty shell that will have its content supplied by an external text file, so that the client does not need to have Flash to create their own tutorials.

Basically, it functions as a simple slideshow: each frame loads a short paragraph of text into a dynamic text field, as well as a corresponding image whose filename is specified in the text file.

I would like all of the jpg files that are specified in the text file to be preloaded before the user begins the tutorial. I've tried to do this by using createEmptyMovieClip(), but I cannot figure out how to get this dynamic content to preload.

Henryww, I've had a look at the sq.fla file, as well as that other thread you linked. It seems to do what I want it to, but I'm having trouble adapting its concepts to my own needs. Statements such as
"var jpgFiles = /:snMatrix["s"+ /:thisSection+ "_" + (l2Counter)].split(",");" are giving me trouble. I presume that this is a reference to a matrix in a database prog., but I'm not sure how it can be bypassed since I'm not using a DB, just a txt file.

Thanks again for all the help, I'm pretty close to figuring this puppy out. Any additional insight you could provide would be stellar!

Cheers,
KM
0
 
LVL 6

Expert Comment

by:henryww
ID: 8194674
as Z stated there are many ways to do it and the simplest way to do a static swf and load it in like Z suggested.

"var jpgFiles = /:snMatrix["s"+ /:thisSection+ "_" + (l2Counter)].split(",");" are giving me trouble. I presume that this is a reference to a matrix in a database prog., but I'm not sure how it can be bypassed since I'm not using a DB, just a txt file."

the example is also loading from the data.txt
u add files (jpg) to a folder, change the txt file for the sections and the images + descriptions ... etc ...

it is a bit complex there, it loads more than one sub-sections (level 2 + different number of images) and generate the menu dynamically. i had removed quite a lot of the code so it only have 1 section (photos)... an easier way to organise the data will be using XML. which is what i am doing for the final site.

let me make a simpler fla for u ... just to preload all the jpgs and show a "start" button when it is all loaded.
0
 

Author Comment

by:kris_mcl
ID: 8196232
Thanks Henry, that would be great if you had a minute to make a simpler fla file.

I really appreciate your help!

cheers,
km
0
 
LVL 6

Expert Comment

by:henryww
ID: 8198498
kris_mcl, i have uploaded a file call sq_trim.zip at the same location ...

which i have changed the text file (data1.txt) and the confusing code in the sqloader movieclip.

u should able to follow it a bit easier ... hopefully ..
let me know if u have problem understanding it ...

cheers
0
 

Author Comment

by:kris_mcl
ID: 8204236
thanks for the new file, henry. It does make more sense, though the dynamic menu portions are still kind of throwing me off.

it seems like there are only a few scripts that are actually involved with the preloading, but I'm having trouble picking out exactly which ones they are among the other things like fadein, fadeout, dynamic menu, etc.

could you point me to just those scripts that are responsible for the preloading?

thanks again for all your help!

0
 
LVL 6

Expert Comment

by:henryww
ID: 8204370
so u don't need the fading? ...

like u just need a very simple way to preload the jpgs (+ create movieclip to as the holder) and ... then?

buttons to netvigate"previous" + "next" when everything is loaded?
0
 

Author Comment

by:kris_mcl
ID: 8204428
yep, that's all I need. Would it be possible to get that file chopped down a little more?

BTW, sorry for being so thick... :)
0
 

Author Comment

by:kris_mcl
ID: 8204445
I should add, all I really want is a way to preload the external jpgs. Once I have that part figured out, I'll be able to use the concept in various movies, with or without effects such as a fadein/fadeout.

thanks man!
0
 
LVL 6

Expert Comment

by:henryww
ID: 8204500
that's ok man .. i know the sample fla is a bit hard to understand, it was intended to do more complex stuffs ...

anyway that shouldn't be too hard, i have to finish off what i am doing now and i will get this done a bit later ...


cheers
0
 

Author Comment

by:kris_mcl
ID: 8204535
awesome, thanks Henry!
0
 
LVL 6

Accepted Solution

by:
henryww earned 400 total points
ID: 8212588
0
 

Author Comment

by:kris_mcl
ID: 8213520
Thanks Henry! That looks like just what I needed. I'll have a closer look at it when I get a few minutes, but it looks very clear on first glance.

This is a concept I'll be able to get a lot of mileage out of, so I'll be sure to hang on to your file as reference.

I really appreciate all the time you took helping me out. Thanks very much.

//km
0
 
LVL 6

Expert Comment

by:henryww
ID: 8213567
u are welcome :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question