1 person found this helpful
Download the CSS (possibly with a query string appended URL so that you get the new copy) first. When the load is completed download the HTML.
So download the CSS to AIR? The HTML pane I'm using is just a display that loads an online webpage - I'm not actually using HTML in AIR. So my programs updates the CSS on the server, and then displays the HTML page. So I'm not sure how downloading CSS would fit in with it. The page gets it's CSS from the server. Would you be kind enougho elaborate please?
I've been playing with this for a while now, but cannot figure out how to download the css file to AIR and make AIR use it on the external HTML file loaded into the HTML pane.
To load the html page, I'm using:
var htmlPane:HTMLLoader = new HTMLLoader();
varSend2 = new URLRequest("my url");
then, once I've checked it's loaded:
I can figure out how to apply external css to html that's been loaded into a text field, but not html loaded using HTMLLoader.
Can you please point me in the right direction so I can research it?
1 person found this helpful
First of all try setting HTMLLoader.cacheResponce to false before you load your HTML.
If that doesn't work try to load the CSS before you load the HTML. To load a CSS use URLLoader. You may try appending new Date().time to the URL. When the CSS is loaded you can see the result to see if the new version is loaded, but other than that you don't do anything with it. Then finally after the CSS is loaded, load the HTML with HTMLLoader. Because the new CSS has ben downloaded and cached, AIR should use the new CSS (in theory )
Something screwy is going on.
I've set up:
var htmlPane:HTMLLoader = new HTMLLoader(); // and later before I load the page...
htmlPane.cacheResponse = false;
htmlPane.useCache = false;
I make a background colour live edit to in my AIR app to black, check the page in Firefox, and the background is black. Then I check the same page in AIR, and the background is the old colour - green. I continually make the editor update the page to a black background, and EVENTUALLY it turns black in AIR. Then other times, it turns black instantly.
If an external browser is seeing the new css, why isn't webkit in AIR - especially when I'm using cacheResponse = false?
The chances are that you're viewing HTML before your new CSS is uploaded fully. Do download the CSS and verify said background colour has been updated - you haven't tried this, have you?
LOL - noooooooo. But I have now, and still having probs.
I made a function that loads the css file (with data and time appended). Once loaded, it goes to the load HTML page function, at the top of which I have trace(event.target.data); so I get an output of the css file data.
I try changing the background color, and the new colour is definitely in the css file output, yet webkit in AIR loads the HTML page with the old color. But it's inconsistent, as sometimes it'll will display the new color just fine.
I'm trying a few other things to see if they work, but any other ideas?
StageWebView is just as hit n' miss, although I will replace htmlLoader with it, as it's simpler to get scroll bars up, so thanks for putting me on to it Kenneth.
As an experiment, I set up a reload button. Whenever one of my css edits doesn't show up, I keep pressing the reload button until it does. Sometimes it takes over ten reloads before AIR loads the new css (even though the new css is instantly available in IE or FF). Then other times, the css is there instantly.
Is there a way to programatically force a cache flush in AIR? htmlPane.cacheResponse = false; and htmlPane.useCache = false; weren't making a difference.
Thanks for your help on this one Kenneth - if anything, I'm learning new AS3 coding from this!
I don't think AIR has a built-in function to flush cache. You may be able to delete files in Tempolary Internet Files from AIR, but I've never tried that
One thing you can try is in your HTML <link> tag append a time stamp to the CSS URL so that your HTML requests new copy of CSS every time.
Thanks for your help on this one Kenneth - I'll give the time stamp a crack.