Ultrashock Forums > Flash > Data Communication
cache problems -flash, php, xml site

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!
cache problems -flash, php, xml site
Old 2008-11-07

I have a base.swf on the page with swfobject.

This base has a dynamic menu that is updated with xml. 2 buttons. Each button loads an external swf and dynamicly asttaches a preloader. Each loaded swf has content coming from an xml file. The xml files are updated with with php from mySQL.

When I view each xml file (actually xmlfile.php) in the browser, they look fine. When i view each external swf, all the content is loaded fine.

The problem is when i go to the actual page. The base loads either movie just fine on the first click of a button. When I click another button, the preloader appears to be loading a new swf. But the same swf is shown as if from the cache. Every click of a button after that does not show the preloader. The same swf is shown as if from the cache.

I am guessing that this is because base.swf is already in the cache. I don't know why the preloader appears to be working on the second click and then never again but a new swf is never shown. If i clear my cache and start over, whichever swf I load first works but I can't get the second one to show.

I have had a base movie with two buttons load 2 different swfs before just fine. This is the first time that the text in the sfws was coming from external files.

Each swf that is called from the buttons has a completely different name and so do the xml files. The only difference in the xmlfile.php files is in the header:

Code:
  list($rmenuRecords, $rmenuMetaData) = getRecords(array(
    'tableName'   => 'rmenu',
'where' => 'category = "Sandwiches"', 
   ));
the other one has a different where clause:

Code:
    'tableName'   => 'rmenu',
'where' => 'category = "Mezza"', 
   ));

thanks for any help. Again, i can visit each file seperately and they appear fine in the browser. A base.swf has always worked for me in the past. All this php and xml stuff is stressing me out. I'm so close to a cool setup, what's going on?
postbit arrow 7 comments | 2733 views postbit arrow Reply: with Quote   
Registered User
djrez is offline
seperator
Posts: 29
2001-10-16
djrez lives in United States
seperator

Ultrashock Member Comments:
djrez djrez is offline djrez lives in United States 2008-11-10 #2 Old  
Last edited by djrez : 2008-11-10 at 16:13.
My external swf files look the same so I only just realized that they were loading as desired. It's the xml file that doesn't load. Here is what I mean:

I have a swf named base.swf that contains two buttons. Each button loads an external swf. Each external swf loads data from an xmlfile.php.

If I press button 1, it loads movie1.swf and the movie1xml.php data just fine.
Then, when I press button2, it loads movie2.swf but again loads the movie1xml.php data.

If I clear the cache and:
Press button 2 first, it loads movie2.swf and the movie2xml.php data just fine.
Then, when I press button1, it loads movie1.swf but again loads the movie2xml.php data.

So for some reason, this shows that everything seems to be setup ok, but the right data never loads. In the broswer, if i go straight to the domain.com/movie2.swf or domain.com/movie1.swf, everything always loads fine. The problem only occurs when using the base.swf to load the external movies.


The only other thing that i can think of to mention is that each movies xmlfile.php is defined in an external .as file when published. That seems irrelevant.

I'd really apprectiate any ideas. Please.
Reply With Quote  
djrez djrez is offline djrez lives in United States 2008-11-11 #3 Old  
I found some information that I thought would solve this problem in the last post of the thread here:
http://forum.tufat.com/showthread.php?t=37258

Each one of my loaded swfs have a main.as file that looks to the root for an undefined xml file as well. _lockroot is also already in these files.


Code:
		defaultSettings();
		settings = new Object();// this object will read the general settings from the xml and it will be further
		// used in the classes
		news = this;
		news["bg"]._visible = false;
		var xmlOb:XML = new XML();
		xmlOb.ignoreWhite = true;
		xmlOb.onLoad = function() {
			cont(xmlOb);
		};
			
		xmlOb.load(_root.xmlFile == undefined ? "xml/menu_sandwiches.php" : _root.xmlFile);

	}

So I changed the load to:
Code:
xmlOb.load("xml/menu_sandwiches.php");
To try and avoid the undefined check mentioned in the thread I linked to above.
And also tried to work in the _root.xmlFile without success. What is the correct way to write this code to avoid the problem that username: symphy says he resolved in the forum I linked to above? I am getting the exact same results still.

thanks,
tony
Reply With Quote  
gdogfunk gdogfunk is offline gdogfunk lives in United States 2009-08-16 #4 Old  
This is a very late reply, but maybe some will find it useful. This first loads the XML data and then starts a timer (in this case 5 seconds) and then reloads the data. The code also places random data after the call to the php file and ensures it loads fresh XML data each time:

Code:
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad=processXMLData;
myXML.load("file.php");

myRandom=Math.round(Math.random()*10000);

clearInterval(myTimer);
myTimer = setInterval(myXML, "load", 5000, "file.php?"+myRandom);
stop();
See if this helps.

-Ryan
Reply With Quote  
djrez djrez is offline djrez lives in United States 2009-08-17 #5 Old  
Interesting. Thanks for this! I don't think i ever solved this and resorted to a frame based solution. I'll definitely check it out in the future.
Reply With Quote  
Nutrox's Avatar Nutrox Nutrox is offline Super Moderator Nutrox lives in United Kingdom 17 Creative Assets 2009-08-17 #6 Old  
If you're using PHP to spit out the XML data then there is no need to use the nasty "random query string" hack, just set the following PHP headers to prevent the response from being cached:

Code:
header( "Pragma: no-cache" );
header( "Cache-Control: no-cache" );
header( "Expires: Sat, 01 Jan 2000 00:00:00 GMT" );
Reply With Quote  
gdogfunk gdogfunk is offline gdogfunk lives in United States 2009-08-24 #7 Old  
Actually, yes, I AM using PHP to spit out XML data. Do you think your PHP header solution might solve my issue in this thread?

Caching XML in loaded SWFs?

I've been stuck on this one for awhile now.

Thank you!!

Ryan
Reply With Quote  
tiran tiran is offline tiran lives in United States 2009-08-24 #8 Old  
one thing to note, and it isn't usually a problem for most sites. But I came across it with some CMS's I was building. If you want it to work on https in IE you have to do this:

Code:
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
The PHP headers prevent the xml from being loaded at all.
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: