Home > Adobe Flash Builder, iPad, iPhone, iPhone Programing Tutorial, Mobile Application > Create and handle button with flex mobile application

Create and handle button with flex mobile application

Today we start with basic control of any development, a Button. Button is main control to take actions from user and respond to it.

First create new application as described in this post.

I choose Blank Template so I only get application file. Now add one view to src. I have added it to my package. Name it Buttons. To create new package, right click on src folder and then select New – >Package. Give name of package and click Finish.

Create New Package

 

 

Now create new view in this package with name Buttons. For that, right click on package we just created and then choose New -> MXML Component follow on screen instructions. This will create new view file for you.

Now replace content of application file with this:

<?xml version="1.0" encoding="utf-8"?>
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
			   xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="160" firstView="com.macymind.views.Buttons">
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
</s:ViewNavigatorApplication>

This will instruct that our fist start up view is Buttons.mxml

Now open Buttons.mxml from project explorer. Switch to design view and add one button from Components panel. If Components panel is not visible then display it from Window -> Show View -> Components

Rename text of button by double clicking on it. Now run your app. It should display button on view.

Now its time to handle tap event form that button. Select button in design view and from Properties panel, click on button beside of On Click label and choose Generate Event handler. This will crate black event handler function and add that button to click event of button.

Now place some trace in that event handler function, debug application and tap on button and see results in Console.

Do comment if you have any problem.

  1. No comments yet.
  1. No trackbacks yet.