A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: reflecting changing XML nodes as clips

  1. #1

    reflecting changing XML nodes as clips

    I'm developing a Flash movie for the Pocket PC that periodically (every minute) retrieves XML content from a web server. Every node in the XML content is reflected within the movie by creating a dynamic clip. And before every new cycle, I remove all the existing clips and start from scratch.

    In my experience, Flash has a bad attitude in garbage collection. Removing clips doesn't necessarily mean removing them from memory. What do you suggest in keeping the memory consumption low?

    What I'm doing so far is recycling the movie every 10 minutes automatically with 'loadMovie("swf file" ,_root)'.

    Plus, I'm considering to deploy it as a standalone application via FlashAssist PRO or Macromedia Stand Alone Player. What do you recommend in terms of syncing XML content from a web server and garbage collection when using one of these tools? And can a projector movie be recycled automatically as well?

  2. #2
    Member
    Join Date
    Jan 2003
    Location
    Australia, Adelaide (SA)
    Posts
    97
    Hi ibec,

    I would suggest that instead of deleting dynamic clips that you re-cycle them into a 'pool'.

    When you reload your XML, hide each of the dynamic clips and call an "init" routine to reset their details. You might want a PoolManager to make this easier.

    Once you parse your XML, tell the PoolManager to give you a new dynamic clip... the PoolManager can either re-activate an existing clip, or create an additional one if none are left in the pool.

    How does that sound to you?

    As for the other options, I'm not sure that reloading the SWF will fix any garbage collection issues as it's still the same instance of Flash, you've just replaced the contents of _level0... of course this would be worth testing to be sure.

    Hope this helps!

    PS: if you want another option for hosting your app, you can create a .NET form with an embedded HTML control using this free source here or here.
    Tim Walters
    Senior Developer
    XML Evangelist
    "XML isn't a language, it's a way of life!"

  3. #3
    Tim,

    The PoolManager idea sounds great!! I'm working on it already. And the work-around - reloading the movie every 10 minutes - actually fixes the garbage collection (no more PDA hangups!).

    Since we're talking Flash/XML anyway, what's the most elegant way in frequently syncing an (updated) piece of XML with a Flash movie, while bypassing all kinds of caching? In IE/JS you can use ActiveX XMLHTTP to load a fresh piece of content periodically. With Flash, I'm not aware of any other way as adding a unique footer to the XML filename to make sure you retrieve the latest.

    How about "streaming" XML, where you don't load a file from disk, but retrieve it directly from a PHP script. If this is possible, does the XML parsing within Flash still works the same way as if you'd load the file from disk? Or other scenario's?

    Cheers,

    I.

  4. #4
    Member
    Join Date
    Jan 2003
    Location
    Australia, Adelaide (SA)
    Posts
    97
    Hi ibec,

    I'm glad the PoolManager idea helped. I'll keep in mind the movie-reload too, might have to try that myself.

    As far as syncing XML, I know of only two options: repeated queries (although I would suggest a 'no changes' response to avoid excess data transfer and processing time, if you get a 'no changes' response then you just keep what you've got, perhaps using a delta-changes type of system), or a Socket Server.

    There's lots of info on these forums about Socket Servers, if that is an option for you... then you could use 'Push' technology (Flash Communications Server gives you this also, for a price).

    As far as Streaming goes, you can load from PHP/ASP/etc exactly the same as from a file (depending on your server cache issues may still require a random suffix on your URL), but Flash won't make the XML available until the whole document is loaded.

    Hope this helps!
    Tim Walters
    Senior Developer
    XML Evangelist
    "XML isn't a language, it's a way of life!"

  5. #5
    I'll stick to the repeated queries with the "no changes" optimization. The socket solution often causes trouble with firewalls.

    With respect to the garbage collection issue, I found out that recycling a scene also removes everything from memory!

    I.

  6. #6
    Tim, just to get back on the garbage collection issue thing...

    What about making the dynamic content and clip handling part of a seperate swf that is (un)loaded periodically by the static swf?

  7. #7
    Member
    Join Date
    Jan 2003
    Location
    Australia, Adelaide (SA)
    Posts
    97
    ibec,

    That sounds like a reasonable idea, you can use a level (eg _level1) to do that. It's important to be aware of secuirty issues, such as sandboxing (check the Macromedia site for details).
    Tim Walters
    Senior Developer
    XML Evangelist
    "XML isn't a language, it's a way of life!"

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