Flash MX + Dreamweaver help

Okay… I’ve made a site… got it all working… its own url and all… now I got a strange problem.

First of all most flash websites I load… first time the flash on the page laods it takes awhile (watch some soorta preloader) then the next time you visit the site it laods the flash up instantly unless its been changed.

Okay for my website… why can’t I do the same? Its the same flash and all (no chanegs applied) it’ll reload instantly if you leave the browser open… but if you close the browser and reopen the site, it reloads the flash all voer again.

I’ve already tested this on the same exact computer… laod 1 page from somewhere with flash… close browser… reopen site laods the flash instant, I turn around open my site laod it… close browser and reload my site it reloads the flash all over again… :*(

So if anyone can, please tell me how its done.

Can you post the URL so I can see if it does it on my machine?

There is no trick to it, the browser caches the file, which is why it loads quicker all the other times. If it isn’t caching your file, then that A)means your browser is set to not cache, but since you tested it, then it might be B)You have some script in your page that is preventing the cache.

Or it might be something else, or nothing :wink:

I’m thinking its the preloader script that causes it, but I read on the forums… this

=================
If one is using the loadMovie or loadVariable commands, you will note problems with updates. Namely, browsers keep both txt and swf files in their cache, so as not to have to reload them again and again from the server. This is great as long as you don’t update often, but if you did update regularly, visitors who came often to your site would not see new data until those files had been purged from the browser’s cache. Since most people don’t mess around with their cache, this can happen quite regularly.
The answer… and as far as this book is concerned the “only” solution, is the following.

The way to solve this is to make Flash always ask for the same file but with a different name. The way to do this is to append a query string to the end of the text file’s name each time Flash executes a call for outside data. For example:

on(release){
loadVariablesNum (“flashdata.txt?x=55”,0);
}

what this is telling the browser is, load “flashdata”, but also querry that txt file for a variable x. This will not write anything to the text file, and as long as you have nothing in the text file which uses x, it wont matter to the flash player. It will of course read the file, and simply not do anything with the variable.
Of course there is a problem. Now that youv’e loaded it with this querry, you can’t use x=55 again. So… here is the solution for that.

on(release){
rn = Math.round(Math.random()*1000000);
loadVariablesNum (“flashdata.txt?reload=”+rn,0);
}

What this will do is add a random number 1 in a million to be precise, to the end of the querry string. Hence, you’re viewer will only have a one in a million chance of not recieving the new data. The million is arbitrary and can be whatever you like. So is the variable named “reload”.

Now to the problem. The reason for the cache is that most people do not want to re download something every time they open a page. If they’ve done so once, they shouldn’t have to over and over again.

As a work around I suggest using the first method for things that you are only going to update once in a while. Each time you update, just be sure to update all of the querry strings in your file to give them a new number.

=====================

Was wondering how I could inpliment that into my site…
and the person I’m doing it for dosne’t want me really spreading it out yet so I’ll priv msg ya the url if ya want to see

Well that code there <B>prevents</B> your movie from being cached.

But from what you were stating before, it sounds like the problem was that your file <B>wasn’t</B> being cached so the preloader kept coming up and it had to load everything all over.

Does it load any quicker the second time around?

Oh, well I just got your PM, went to the links.

I saw the preloader the first time, then when I refresh the page it shows up fine and dandy, right quick.

But your right… if you close and reopen, it starts from scratch.

Eh nope… it’ll reload all flash on the site as if it has never been laoded before… regular images/text on the site loads near instantly after first time the site is loaded.

I was looking around for maybe cookies or soemthing to retain the cache of the flash without me changing the preloader I use (since I belive its the cause) Hoping theirs another way though without altering the nice preloader :confused:

I dunno if you are willing to post this… but what code are you using for your preloader?

PS: Just in case you didn’t see, I posted twice last time.

If you notice passing the “intro” and loading the main page (Has the menu and all) lookinh up top ahs some the code left over from the preloader (or wa sit while its loading?) and I belive its the cause… I’m hoping I can somehow avoid removing the preloader and using soemthing else though :confused:

This is really strange, I can go to your page, see the preloader, refresh, and not see it. Then go to a few other pages, and back, and still not see it. But if I close my browser window and open it in a new one and go back, I see your preloader all over again.

2 Scenes

the preloader is 2 frames (and the little bar down bottom)

Frame one

total_bytes = _root.getBytesTotal();
loaded_bytes = _root.getBytesLoaded();
remaining_bytes = total_bytes-loaded_bytes;
percent_done = int((loaded_bytes/total_bytes)*100);
bar.gotoAndStop(percent_done);
ifFrameLoaded (“Movie”, 98) {
nextScene();
}

Frame 2

gotoAndPlay(1);

the bars and such have identifiers to them to attach the values so the numbers/bar changes (which seem to work just fine for all pages, and is very easily changed to fit any page/load size)…
Sorrat reason want to keep it sicne I can easily change the preloader aspects n all and its informative for the user (had one to display time remaining cept thats soorta messy) heh

*Originally posted by lostinbeta *
**This is really strange, I can go to your page, see the preloader, refresh, and not see it. Then go to a few other pages, and back, and still not see it. But if I close my browser window and open it in a new one and go back, I see your preloader all over again. **

Go through some pages (high speed link one) look up top at the url… sometiems you cna notice the preloader code up their slightly) I belive thats what causes the constant reload… if only their was a way to… Tell IE that tis laoded “Thisfile.swf” and not need to reload it again…

Ohhhh, this preloader again. Hmm, I wodner where everyone is getting this. ifFramesLoaded has been deprecated I believe, and going by frames in a tween is way tedious, but here is something I think might help.

total_bytes = _root.getBytesTotal();
loaded_bytes = _root.getBytesLoaded();
remaining_bytes = total_bytes-loaded_bytes;
percent_done = int((loaded_bytes/total_bytes)*100);
bar.gotoAndStop(percent_done);
if (loaded_bytes == total_bytes) {
nextScene();
}

What I did there was changed your ifFrameLoaded statement to an if statement. And that if statement checks to see if the loaded bytes are at the same amount as the total bytes. If the loaded and total bytes are equal, that means that your movie is done loading, so it is directed to play the next scene.

I know you don’t want to redo your preloader, but if it comes to that… http://www.kirupa.com/developer/mx/percentagepreloader.asp that tutorial is much simpler than what you are currently using and is more updated than the one you are using as well.

K i’ll try it out, I gotta get goin for a bit to checkup on the server n all thxs for the help :stuck_out_tongue:

I gotta go too.

No problem. And good luck :slight_smile:

Anyone else able throw in some possible solutions… the above 2 didn’t work :hangover:

Alright, I have similar code to yours.

code:

first action frame:

loadedbytes = getBytesLoaded();
totalbytes = getBytesTotal();
loadedkbytes = Math.ceil(loadedbytes/1000);
totalkbytes = Math.ceil(totalbytes/1000);
if (loadedbytes == totalbytes) {
nextScene();
}
frame = int(loadedbytes/(totalbytes/100));
tellTarget (_root.loader) {
gotoAndStop(_root.frame);
}

second action frame:

gotoAndPlay(1);

what i did was created 5 text boxes with 0s in them and made each one a variable. i named the first box totalbytes, second box loadedbytes, third one loadedkbytes, fourth one totalkbytes, fifth one frame. the text boxes are dynamic text.

put the preloader in the first scene and your movie in the second scene, if you haven’t already.

hope this helps.

again this gets saved in your cache, so the second time you view the page, the movie will load up very fast and you won’t even see the preloader.

if you want to test it, just clean out your cache and refresh your page.

The preloader codes before did the same thing, but his page wasn’t getting cached for some reason.

that’s weird. the code i’m using is absolutely wonderful. if you click on my website, you can see how it works. but why it wouldn’t cache, i don’t understand.

Yeah, neither do we.

The tutorials I sent him to preload perfectly too, but if you close out the window and go back, its no longer cached.

Very strange indeed it is.