A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: as3 xml local storage from url

  1. #1
    Senior Member
    Join Date
    Aug 2006
    Posts
    293

    as3 xml local storage from url

    i am hoping that someone can put me right on this question (apologies if this the wrong forum too)...

    i have an .ipa file that uses xml for it's content. i can load the xml/images etc... fine from both a url and also locally on the handset.

    but what i wanting/trying to do is for the .ipa to check to see if there is an updated xml doc/images from the url - if there is then it downloads/saves the xml doc and any associated images to a local folder/location - if there isn't (or the handset can not access the internet) it simply loads up the xml and images locally.

    i have seen a few methods of doing this - but am not sure how it all ties together with flash?

    has anyone done this before? or know of any good examples online?

    here's hoping!

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    The only way I could imagine is that the xml file has a date and time when it was uploaded or created, while the date and time of a previous xml file is somewhere stored as a cookie or shared object. If the xml file cannot be retrieved because of lack of internet, then a error message will be thrown as an event listener and that function can contain the url for a local xml file. That is how I would do it.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    thanks for the reply - that kinda makes sense how would i rewrite the following xml to do that?
    Actionscript Code:
    stack_gallery_01.load_gallery("http://www.domain.com/xmldir/this.xml");
    stop();

    could i just do something like

    Actionscript Code:
    stack_gallery_01.load_gallery("http://www.domain.com/xmldir/this.xml");
    else
    stack_gallery_01.load_gallery("this.xml");
    stop();

    the other question is regarding the actual updated/new images - how do i get them to the device? is there any cache features in cs5 that would do this? or is that a whole fresh "can o' worms"?

    i also found this article which is pretty much exactly what i am trying to do - but am none too familiar with the methods outlined.

    and the source that i can download is not self explanitory enough for me to hit the ground running...

  4. #4
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...sorry, i manage to double post!
    Last edited by WWFC; 06-28-2011 at 04:22 AM.

  5. #5
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    oooh! downloading the images to a local defined directory...
    this article looks like the 'kiddie' - how would i get this to fire from flash? would i be asking for the php or xml? or both?

    and could i include cancerinform's suggestion in doing so?

    would it just be an eventlistener?

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You add a new node or attribute in your xml, where the date is written and you call that and compare with the date stored in the cookie. For downloading check this suggestion:

    http://board.flashkit.com/board/showthread.php?t=823794

    You could download a zip file with images and unzip the file. Here is a tool to do that:

    http://blog.gafmediastudio.com/2010/...3-unzip-class/
    Last edited by cancerinform; 06-29-2011 at 09:21 AM.
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...still trying to get my head around this!!

    would i put the node into each <photo>.....
    PHP Code:
    <?xml version="1.0" encoding="utf-8"?>
    <photos>
        <photo>
            <filename>animals_400x260_01.jpg</filename>
            <title>Animals - Title 01</title>
            <description><![CDATA[<p><a href="http://www.blahblah.com" target="_parent">Lorem ipsum dolor sit amet</a>, consectetur adipiscing elit. Quisque at ante sit amet erat laoreet <u>fermentum</u>. Quisque nec nisl. Nam scelerisque cursus dolor.</p><p><span class="highlight">This text is dynamically loaded from the external XML file. This textfield supports HTML and CSS.</span></p>]]></description>
        </photo>
    </photos>
    or just into the header?...

    PHP Code:
    <?xml version="1.0" encoding="utf-8"?>
    with regard the images - i did try using a sharedobject to store the images, which did store the image pulled from the url but it never updated the image when i changed it online.

    those two links are useful but i'd need the images to go to the local directory automatically not user directed as the majority of users won't know where to put them.
    but i guess there are security issues? or does ios operate differently?

    i've seen that air has some local capabilities, but have never really used it.
    i've got all the cornerstones of info - but no idea how to get them playing together nicely! :-(

    ***holds out hand and hopes someone will hold it***

  8. #8
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You put put a single node somewhere at the top of the xml file, since you want to know if the xml file is new or not.
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center