How to install a .deb file
To install package called package.deb type the following command (make sure that all dependencies are installed)
sudo dpkg -i /path/to/folder/package.deb
To install package called package.deb type the following command (make sure that all dependencies are installed)
sudo dpkg -i /path/to/folder/package.deb
The goal of this post is to show how we can create a radio button group so users can switch on and off when using vnkeys as the swf above. To create TextArea and TextInput we use input components that follows vnkeys (see this how to for details). Bellow is our code example where we use flex RadioButtonGroup and RadioButton to create on/off options. We use Repeater to loop through options that we get from KeyConverter.getKeyMapOptions() This is done by calling init function initOptions() which fills element “options” with an array of available mapping types. On each option we attach function onMappingTypeChange as listener for onchange event so we can update mapping type on each KeyConverter instance.
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:flex="org.vnmedia.flex.*" creationComplete="initOptions();"> <mx:Script> <![CDATA[ import mx.controls.RadioButton; public function initOptions():void { options = area.getKeyConverter() .getKeyMapOptions(); } public function onMappingTypeChange(e:Event):void { var radio:RadioButton = RadioButton(e.currentTarget); var item:Object = radio.getRepeaterItem(); text.getKeyConverter().setMapType(item.data); area.getKeyConverter().setMapType(item.data); } ]]> </mx:Script> <flex:FlexTextArea id="area" vnkeyType="VNI" height="50" width="220" x="50" y="50"> </flex:FlexTextArea> <flex:FlexTextInput id="text" y="120" x="50" width="220"> </flex:FlexTextInput> <mx:Array id="options"/> <mx:HBox id="hb" x="50" y="150"> <mx:RadioButtonGroup id="radioGroup" /> <mx:Repeater id="radioRepeater" dataProvider="{options}"> <mx:RadioButton id="radioButtons" label="{radioRepeater.currentItem.label}" group="{radioGroup}" change="onMappingTypeChange(event);" /> </mx:Repeater> </mx:HBox> </mx:Application>
In the package org.vnmedia.flex we find two subclasses of Flex controls class. FlexTextInput is extending TextInput and FlexTextArea extending TextArea. Those two inherit all functionalities from their parent. We just added some more code handling the typing since TextInput and TextArea behaves unlike TextField. It is simple to use. You just need to declare namespace for org.vnmedia.flex, I call it “flex” in example bellow.
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:flex="org.vnmedia.flex.*" layout="absolute"> <flex:FlexTextArea id="area" vnkeyType="VNI" height="50" width="220" x="50" y="50"> </flex:FlexTextArea> <flex:FlexTextInput id="text" y="120" x="50" width="220"> </flex:FlexTextInput> </mx:Application>
You can type vietnamese using VNI input method (see)
vnkeys was designed to work well with Textfield. I guess that you feel that the replacement is a little bit annoying when using it with Flex TextInput and TextArea. Here is an example when using it with TextField. It runs smoothly and you experience a bit faster. This is something that we will try to improve in the future version.
Bellow is a table on how to hit the keyboard (left hand side) to get the vietnamese letter (right hand side)
VNI => Vietnamese
a1 => á
a2 => à
a3 => ả
a4 => ã
a5 => ạ
a6 => â
o7 => ơ
a8 => ă
d9 => đ
We do not implement all possible ways to type a vietnamese word. Example, there are many ways to type the word trường (school)
But in vnkeys you can only do that with the first four ways in this list. Another word, we implemented only the “natural ways” of typing. And natural means that you type in an order as you write on paper.
In actionscript 3 one can not use private scope for constructor and you need a workaround to implement simgleton pattern. Following is one way that I use
package { public class Singleton { private static var instance:Singleton; private static var isAllowedInstance:Boolean; public function Singleton() { if (!isAllowedInstance) { throw new Error("Please use " + "Singleton.getInstance()" + "instead of new keyword"); } this.init(); } private function init():void { trace("init stuffs"); } public static function getInstance():Singleton { if (null == instance) { isAllowedInstance = true; instance = new Singleton(); isAllowedInstance = false; } return instance; } public function singsing():void { trace("singsing"); } } }
This will cause an error if someone uses the new keyword
var singleton:Singleton = new Singleton();
It will work fine if you use it like this
var singleton:Singleton = Singleton.getInstance();
This article is aimed to you whom use svn in linux environment. If you are using windows and Tortoise this post may be more interesting.
Here are two ways to get revision number when you build your project. The first one is a complete method to get this number and the second one will give you this number including a trailing if there is (see). In both examples I try to get the current revision number of Zend Framework …
Using svn
In this case we use “svn info” and put the data into xml file svninfo.xml. After that we load in the data using xmlproperty and select the revision number. Your target would look like this
<target name="get-revision"> <exec executable="svn" output="svninfo.xml"> <arg line="info --xml Zend" /> </exec> <xmlproperty file="svninfo.xml" collapseattributes="true" /> <property name="svn.revision" value="${info.entry.revision}" /> <echo>${svn.revision}</echo> </target>
And after running this target you get an output as bellow and the echo statement should give you 17746
<?xml version="1.0"?> <info> <entry kind="dir" path="Zend" revision="17746"> <url> http://framework.zend.com/svn/... ...framework/standard/trunk/library/Zend </url> <repository> <root>http://framework.zend.com/svn/framework</root> <uuid>****</uuid> </repository> <wc-info> <schedule>normal</schedule> <depth>infinity</depth> </wc-info> <commit revision="17740"> <author>****</author> <date>2009-08-22T02:53:32.295192Z</date> </commit> </entry> </info>
Using svnversion
This case is really simple and you don’t need an output file. However, the result may contain none numeric character and you need to convert it if you do need an integer. The easiest way is to parse this as an int in your application before you start using it. In this example the echo statement should print out something like 17746M
<target name="get-version"> <exec outputproperty="svn.revision" executable="svnversion" dir="Zend" /> <echo>${svn.revision}</echo> </target>
If you need to run a php script in Linux environment via putty or other clients and want to close client without terminating the running process of php script you may need to do as bellow. The keyword is nohup …
nohup php policyserver.php > /dev/null 2>&1 &
Sometimes ago I started to learn actionscript 3 and the go was to code for the game nought and crosses with a simple AI. To save time I used Flex componnents to create button and other containers. I was running on problem to add my application to flex application. Flex refused to add my objects as child in Flex application and the solution was adding my objects in an UIComponent object and added this object to flex application. Bellow is another way to code and is completely equivalent to what mensioned above.
The procedure is simple. You create a “container” class by extending Flex UIComponent. Bellow is the container class for my nought and crosses. I guess that you are familar with the code. You don’t need to pay much attention to create-method. However, newGame, playBack and addStatusListener are worth to notice. And you can find the reason on the next paragraph.
package vnmedia.games.nac { import mx.controls.Text; import mx.core.UIComponent; import vnmedia.games.nac.ai.AiComm; import vnmedia.games.nac.ai.BaseAi; import vnmedia.games.nac.core.CoreComm; import vnmedia.games.nac.core.Game; import vnmedia.games.nac.gui.Client; import vnmedia.games.nac.gui.GuiComm; public class FlexNac extends UIComponent { private var client:Client; private var game:Game; private var status:Text; public function FlexNac() { // create client, game and other necessary this.create(); try { this.addChild(this.client); // start an new game this.game.newGame(1); } catch(e:Error) { trace(e); } } public function newGame():void { this.game.newGame(1); } public function playBack():void { this.client.playBack(); } public function addStatusListener(t:Text):void { this.client.addStatusListener(t); } private function create():void { var aiCoreComm:CoreComm = new CoreComm; var guiCoreComm:CoreComm = new CoreComm; var aiComm:AiComm = AiComm.getInstance(); var guiComm:GuiComm = GuiComm.getInstance(); var Ai:BaseAi = new BaseAi(); aiComm.attach(Ai); aiCoreComm.setClientComm(aiComm); guiCoreComm.setClientComm(guiComm); guiComm.setCoreComm(guiCoreComm); aiComm.setCoreComm(aiCoreComm); this.client = new Client(24); guiComm.attachClient(this.client); this.game = new Game('X'); this.game.aiCoreComm = aiCoreComm; this.game.guiCoreComm = guiCoreComm; // aiCoreComm.attachGame(game); guiCoreComm.attachGame(game); this.client.addStatusListener(status); } } }
Now you know how to create a “container” class for your application. The next step is to include it in a Flex application. There are two way to add it to Flex application. You can use mx:Script and code with actionscript style (see) or just do as simple mxml example bellow where I use Flex standard box components and button component.
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:vn="vnmedia.games.nac.*" layout="absolute"> <mx:Style source="beige.css"></mx:Style> <mx:VBox styleName="firstVBox"> <mx:HBox styleName="menuHbox"> <mx:Button id="newGameButton" click="nac.newGame();" label="New game"></mx:Button> <mx:Button id="playback" click="nac.playBack();" label="Playback"></mx:Button> </mx:HBox> <mx:HBox x="10"> <vn:FlexNac id="nac"></vn:FlexNac> </mx:HBox> </mx:VBox> <mx:VBox styleName="secondVBox"> <mx:HBox styleName="statusHBox"> <mx:Button label="Status"></mx:Button> <mx:Text id="stat" styleName="status" text="You: 0 Computer: 0" creationComplete="nac.addStatusListener(stat);"> </mx:Text> </mx:HBox> </mx:VBox> </mx:Application>
Now when you finished reading the code you should notice that I added my nought and crosses with a tag
<vn:FlexNac id="nac"></vn:FlexNac>What hapened was that I created my own namespace vn. You can find it as an attribute in mx:Application element. You should get a picture how to create your own component for Flex application by now, right?! and of course if you have a reason :-p
Now we go back to those 3 methods mensioned in the beginning. I just created those public methods so I could access from Flex application, no more no less. Another way is that I could make “game” and “client” accessible. One last thing for those whom do not use mxml. The attribute id refers to the created object and you can see it in the beginning where I used in click event
<mx:Button id="newGameButton" click="nac.newGame();" label="New game"></mx:Button> ...
And finally the result
This post is for you who are using Tortoise in windows environment and want to get the highest committed revision number when running an ant build script. This number can be useful when handling the version of the static files/contents. Here is a simple ant target
<target name="get-revision"> <exec executable="subWCRev.exe"> <arg value="${srcBaseDir}"/> <arg value="${srcBaseDir}/revision.build"/> <arg value="${srcBaseDir}/deploy/revision.properties"/> </exec> </target>
Where ${srcBaseDir} is the top directory of svn checkout (working copy), ${srcBaseDir}/revision.build is the template file and ${srcBaseDir}/deploy/revision.properties is the output file.
And content of the file revision.build
common.svn.revision = $WCREV$
Where $WCREV$ is the placeholder for the highest committed revision number. You can find more placeholders by running subWCRev.exe in cmd-promt.
The output to the file revision.properties will be, for instance
common.svn.revision = 1001
Enjoy!