Using Compact Data Formats in FlashLite 1.1

Recently I have been involved in some FlashLite 1.1 development that requires a certain level of online data interaction. With memory being at a premium on Mobile devices I have been spending many a spare moment looking at efficient data transfer methods.

Stepping back into FlashLite 1.1 (flash 4/5) scripting has been a nostalgic experience. The halcyon days of ActionScript 0/1 were where I broke my teeth, so to speak, on flash. It has been an eye opener also to return to using Perl as well in order to format data efficiently for consumption in my simple FlashLite 1.1 applications.

In these days of XML, SOAP, SQL, and huge component frameworks, it has been nice to go back the the “demo days” of flash and try and eak every byte out of my data format. Remember of course, no XML or SWX support in FlashLite 1.1.

So what have i been playing with? How about a Live London Tube Status FlashLite 1.1 application?

The Data format?

lnID0=0&lnID1=0&lnID2=0&lnID3=0&lnID4=6&
lnID5=0&lnID6=0&lnID7=1&lnID8=0&lnID9=0&
lnID10=0&lnID11=0&itemLoaded=true

The lack of native structured data in FlashLite 1.1 means you have to think differently about what you are conveying, where best to store it, and how to access it. The example format above allows me to form references between pseudo-arrays in the FlashLite file that store much bulkier text labels, those strings can then be used multiple times in the application.

First I have a pseudo-array with my representation of the London Tube Lines.

lineNames0 = "Bkrloo";
lineNames1 = "Cntrl";
lineNames2 = "Crcle";
lineNames3 = "Dstrct";
lineNames4 = "Est Lndn";
lineNames5 = "Hmrsmth & Cty";
lineNames6 = "Jblee";
lineNames7 = "Mtropltn";
lineNames8 = "Nrthrn";
lineNames9 = "Pcdilly";
lineNames10 = "Vctria";
lineNames11 = "Wtrloo & Cty";

Also I store my interpretation of the common tube status’ in a similar pseudo-array.

lineStatus0 = "Normal Service";
lineStatus1 = "Short Delays";
lineStatus2 = "Long Delays";
lineStatus3 = "Suspended";
lineStatus4 = "Part Suspended";
lineStatus5 = "Part Closed";
lineStatus6 = "Planned Closure";

Then once the data has loaded, note the last name value pair (itemLoaded=true) it allows my load script to spot when all the data is in the application. I perform a little loop operation to link my labels to line id’s and then use the value of the loaded variable to set the frame of a “status” movie clip.


itemTotal = 0;
i = 0;
/*
loop through the loaded data, we know that there are not more than 11 Tube lines in London, at the moment.
*/
while(i < 12) { serviceLine = "/serviceBoard/serviceLine"; lnStatus = eval("/channelData_mc/:lnID" add i); lnLabel = serviceLine add i add "/:_serviceItemLabel"; stLabel = serviceLine add i add "/:_serviceStatusLabel"; lnItem = serviceLine add i add "/serviceItemLine"; stItem = serviceLine add i add "/serviceItemStatus"; set((lnItem add "/:lnNum"), i+1); set((stItem add "/:lnNum"), (lnStatus+1)); eval(serviceLine add i add "/:_serviceItemLabel") = eval("/channelData_mc/:lineNames" add i); eval(serviceLine add i add "/:_serviceStatusLabel") = eval("/channelData_mc/:lineStatus" add lnStatus); tellTarget(lnItem) { gotoAndStop(lnNum); } tellTarget(stItem) { gotoAndStop(lnNum); } ++i; }

The Result?

Download the Live London Tube Status FlashLite 1.1 Application for Mobile Devices.

Leave a Reply

Your email address will not be published. Required fields are marked *