Archive

Archive for March, 2009

XML in Production (lazy)

March 30th, 2009

I’m working a lot with international sites and there can often be times where the deadlines are short, customers aren’t so fast as I wish they where with feedback e.g.

This often messes up translations with XML files. They needs to be resend for changes and as the sites takes interaction you can find that things are missing.

Here is a small tip if you are running out of time, make sure your XML structure is simple, as well make sure that you are using unique id attributes. Then you can just combine the XML files and you don’t really need to go thru hours of copy/paste work.

A small example.
XML 1
<xml>
<gui>
<item id=”replay”>REPLAY</item>
<item id=”start”>START THE GAME</item>
</gui>
</xml>

XML 2
<xml>
<gui>
<item id=”volumeOff”>TURN ON VOLUME</item>
<item id=”volumeOn”>TURN OFF VOLUME</item>
</gui>
</xml>

So what I do is just to add on and on and combine the XML;s.

var copy:XML = levelLoader.getXML("data/en.xml");
var copy1:XML = levelLoader.getXML("data/en01.xml");
var copy2:XML = levelLoader.getXML("data/en02.xml");
copy = copy.appendChild(copy1.*);
copy = copy.appendChild(copy2.*);
 
var volumeOff : String = copy.gui.(@id=="volumeOff");

Flash , , , ,

Bandwidth tester for server.

March 12th, 2009

So I needed to try out some speed from a company server. You can always take a bandwidth test on your computer to see your own bandwidth speed (http://www.speedtest.net/), but when placing files on a server you also need to consider that server speed, the connection and the whole way of roadblocks to your computer.

First step is to create a dump file, I just took a ordinary file and renamed it to “data.bin”.

Next step is the speed tester itself. If I figure it out correctly I can take the downloaded time and run it against the downloaded bits to get the speed.

var downloadTime:Number = (getTimer() - timeMarker) / 1000;
var bits:Number = file.bytesTotal * 8;
var bps:Number = bits / downloadTime;

Something like “bps = download size in bits / download secs”

To think of here is that when calculating file size 1mb = 1024kb, but when going for bits whe have 1kbps = 1000bps. Look at this (http://web.forret.com/tools/bandwidth.asp).

How to use
So anyway I created this simple zip file, unzip it on your server, place a file/files in the same folder and then set the paths from the html file, look at line 92“flashVars”, “files=data.bin”, use , to add more files to load as an array.

This way I could for e.g. check that my connection is 9.6mbit to the net but the speed from my hosting server is 4.5mbit.

Download the Server Speed Tester. bandwidthtester

Life , , , ,