Topic: embeding text / xml files in the widet SWF

Hi!

I'm using Ubuntu / mtasc / swfmill to build my widget. Works great in Flash 8 player in the browser but on the device it seems to run into memory constraints. Problem is that I'm trying to allocate bunch of long strings in my code which in sum exceed 32k (perhaps I'm running into the infamous 32k static allocation problem). My work-around of splitting the strings into multiple classes worked on the browser player but Chumby still doesn't like it.

So instead of allocating the strings in the code I want to do what I was trying to do in the first place: put the strings in a .xml or .txt file, embed it in the .swf and somehow load it dynamically in the code. I searched deep and wide but could not find a way of doing this with mtasc / swfmill. Perhaps I'm misunderstanding something here but I think XML.load() only works with URLs. I also did not find syntax for how to embed text file resources in the mtasc / swfmill application definition (the <library> only seems to allow clips).

If at all possible I would prefer not to load the text data from a remote server (hence I'm trying to embed).

Let me know if you know of a way to do this. 
Many Thanks

Re: embeding text / xml files in the widet SWF

Here's what I'd recommend - since the string is XML, and you intend to parse it anyway, why not parse it in advance and store it as a structured Object in Actioncript (basically JSON)?

The Control Panel does this for its timezones - the timezones come from the upstream source in an XML file.  Whenever that file is updated, the Control Panel has some code to read the XML, parse it, and output Actionscript code of a single structured Object that represents the same data (actually it also performs some coordinate transforms to match the projection of the map). This Actionscript is then included in the Control Panel the next time it's built.

In your case, I'd probably whip out a small movie that reads the XML and traces out a class definition with a single static variable that initializes to the structure you want to use, cut and paste the output to a .as file, then I'd simply use that class in my movie.  Obviously, you could also use some other scripting language, such as Perl, python, etc.

Re: embeding text / xml files in the widet SWF

This is a good idea. The strings I'm dealing with are not actually XML but I can pre-parse them into AS code as you suggested and include it in the compilation. This will probably increase the size of the .swf but that might be OK.

So strange that Flash / mtasc / swfmill does not allow you to include local resources other then media clips.

Thanks for prompt response!

Re: embeding text / xml files in the widet SWF

pete0877 wrote:

So strange that Flash / mtasc / swfmill does not allow you to include local resources other then media clips.

Well, a MovieClip is simply a subclass of Object - there's no reason why a MovieClip can be completely devoid of any graphics and simply contain Actionscript.  In other words, you can make a MovieClip in the library that's linked to the class you generated with your script, then use attachMovie() to pull an instance of that MovieClip from the library.

It won't make your movie any smaller, since the object will be there is any case (especially is the data is static), so I don't see any particular advantage to doing it this way.

Re: embeding text / xml files in the widet SWF

Duane wrote:
pete0877 wrote:

So strange that Flash / mtasc / swfmill does not allow you to include local resources other then media clips.

Well, a MovieClip is simply a subclass of Object - there's no reason why a MovieClip can be completely devoid of any graphics and simply contain Actionscript.  In other words, you can make a MovieClip in the library that's linked to the class you generated with your script, then use attachMovie() to pull an instance of that MovieClip from the library.

It won't make your movie any smaller, since the object will be there is any case (especially is the data is static), so I don't see any particular advantage to doing it this way.

Ahh - the classic "ActionClip" - those were the days. smile

Cheers.