Skip navigation
Currently Being Moderated

AS3 AIR question

Dec 21, 2011 9:37 PM

Hi

 

I have a desktop AIR app that sends vars to a php page, which then rewrites a new css style file.  After the vars are uploaded, I set off a refresh function in AIR that refreshes an html display pane, so you can see the css style changes on the html page.

 

I was working great, but since I have changed hosts, I find I have to send the vars twice to see changes. 

 

I thought maybe the problem was that AIR was displaying the new page before php had a chance to write the new css file, but even after putting a 2 second delay timer on the refresh, the problem still exists.

 

I have also made the refresh function  URL request append date and time as in:

 

varSend2 = new URLRequest("http://www.blah.com/"?time=" + new Date().getTime());

 

Is there a trick to force the html display in AIR to display the new CSS settings first time around?

 

Thanks guys.

 

Shaun

 
Replies
  • Currently Being Moderated
    Dec 22, 2011 5:06 AM   in reply to celebritymusic

    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.

     

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.uk/

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 23, 2011 9:04 AM   in reply to celebritymusic

    AIR is using cached old CSS, so if you download the new one AIR should use the new CSS - that's my theory.

     

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.uk/

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 27, 2011 2:31 AM   in reply to celebritymusic

    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 )

     

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.uk/

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 27, 2011 12:42 PM   in reply to celebritymusic

    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? 

     

    --

    Kenneth Kawamoto

    http://www.materiuaprima.co.uk/

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 28, 2011 3:13 AM   in reply to celebritymusic

    Try StageWebView to see if the CSS gets updated.

     

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.uk/

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 29, 2011 9:01 AM   in reply to celebritymusic

    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.

     

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.uk/

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points