Once you create a New Project in FlexBuilder, and choose to create a new application, the following code is what you start with :
As you can see, the first line indicates that the XML syntax is to be strictly followed. Then, the Application is created, and all other UI components are to be placed within the Application tag.
<?xml version="1.0" encoding="utf-8"?>
<mx:application mx="http://www.adobe.com/2006/mxml">
</mx:application>
Lets have our first, "Hello World" Program,
The above program, creates a simple application, with a single button. On clicking the button, you get a "Hello World" alert box shown.
<?xml version="1.0" encoding="utf-8"?>
<mx:application mx="http://www.adobe.com/2006/mxml">
<mx:script>
<![CDATA[
import mx.controls.Alert;
private function sayHello():void{
Alert.show("Hello World");
}
]]>
</mx:script>
<mx:button label="Say Hello" click="sayHello();" />
</mx:application>
The click event handler for the button is the sayHello() function. Much of the code is self-explanative if you know object oriented and event-handling concepts, along with some simple javascript.
No comments:
Post a Comment