Solved

Skip preloading if movie is already downloaded

Posted on 2010-09-23
8
286 Views
Last Modified: 2013-11-11
I've got a preloader that was programmed by someone else... the problem is that the movie that it's loading appears on 5 different pages of the same site, and it's forcing the movie to redownload itself every time. I just need a way for it to skip the download if the file is already in cache. I thought this could be done using a simple if-statement to check if the bytes loaded equaled bites total, but it didn't work. Some assistance would be nice :) Thanks
onClipEvent (load) {
	total = _root.getBytesTotal();
}

onClipEvent (enterFrame) {
	loaded = _root.getBytesLoaded();
	percent = int(loaded/total*100);
	text = percent+"%";
	gotoAndStop(percent);
	if (loaded == total) {
		_root.gotoAndPlay(2);
	}
}

Open in new window

0
Comment
Question by:truromeo4juliet
  • 5
  • 3
8 Comments
 
LVL 2

Expert Comment

by:phodges4
ID: 33748364
are all 5 pages within the same swf file? or are they 5 different web pages? The only way you will be able to stop redownloading is if the loader is in a swf and that's all located on one web page .. also, if the file is in cache, it wont physically download the file again so there is no harm in that unless you want to skip an animation or something.  

please post the code that loads the external swf..

If you are just trying to skip an animation you can do a simple check in the loader to see if the percentage is ever anything less than 100 and if it is, gotoAnPlay() passed the animtion..

if you need some examples let me know .. or if I'm wrong please better specify the problem .. thanks
0
 
LVL 5

Author Comment

by:truromeo4juliet
ID: 33748862
it's all one swf file... it's an HTML site (6 html pages in all), each page has the same SWF embedded into it... for some reason, each page, the first time I go to it, has to load the SWF... afterwards, it loads from cache when i revisit that particular page... Is there any reason for this?
0
 
LVL 2

Expert Comment

by:phodges4
ID: 33748919
hmmm .. that's a strange one, the cache should have picked up the same file as long as the URL is the same  .. do you have this posted anywhere on the interwebs so I can sneak a peek?
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 5

Author Comment

by:truromeo4juliet
ID: 33749008
http://permanentmakeupbyadriana.com/

the only difference per page is that each page is referenced by the swf file to tell it what button should be highlighted in the SWF. You can see in the website.
0
 
LVL 2

Accepted Solution

by:
phodges4 earned 500 total points
ID: 33749132
it's because of the querystring variable .. you can fix this by moving button=3 into the flashvars property
(note i put flashvars in there twice)
you can check http://kb2.adobe.com/cps/164/tn_16417.html for more info on flashvars

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
           codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,24"
            width="766" height="414">
    <param name="movie" value="flash/header_v8.swf"  />
    <param name="quality" value="high"  />
    <param name="flashvars" value="button=3"  />
    <param name="menu" value="false"  />
    <!--[if !IE]> <-->
    <object data="flash/header_v8.swf?button=3"
             width="766" height="414" type="application/x-shockwave-flash">
     <param name="quality" value="high"  />
     <param name="flashvars" value="button=3"  />
     <param name="menu" value="false"  />
     <param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer"  />
     FAIL (the browser should render some flash content, not this).
    </object>
     <![endif]-->
   </object>
0
 
LVL 5

Author Comment

by:truromeo4juliet
ID: 33750416
should the if !IE section still have button three in the object data:

<object data="flash/header_v8.swf?button=3" etc...

?
0
 
LVL 5

Author Comment

by:truromeo4juliet
ID: 33750436
nevermind, got it! Thanks so much for the help :)
0
 
LVL 5

Author Closing Comment

by:truromeo4juliet
ID: 33750441
Thanks so much.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
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 how to record live broadcast.

810 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