Monday 18 April 2011

Actionscript 3.0 : Adding A Version Number

To keep track of different versions of your application you should introduce version numbers. I place my version numbers in the 'context menu' (when you right click on the Flash). 


To do this we first create a variable to hold the version number, below is an example:


private var versionNumber : String = "1.0";


Then we create a new context menu and a new ContextMenuItem (this is an item which sits in the context menu), we provide the ContextMenuItem  with a String parameter which is the version Number. We have to push the menu item  into the context menu that we have just created and set the applications context menu to the new one. Make sure you set your objects to null to keep your application clean. 



var cm : ContextMenu = new ContextMenu();
var versionN : ContextMenuItem = new ContextMenuItem("version: " + versionNumber);
cm.customItems.push(versionN);
contextMenu = cm;
versionN = null;
cm = null;

No comments:

Post a Comment