LinkButton using ActionScript

August 12, 2009 at 11:40 am | Posted in Flex | Leave a comment

Introduction:

From this simple Flex Example, one can easily understand about ActionScript. Try this in your own way and learn more.

Source Code:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” creationComplete=”createbutton();”>
<mx:Script>
<![CDATA[

import mx.controls.LinkButton;
import mx.controls.Image;

var link:LinkButton;
var image1:Image;

public function createbutton():void{
link=new LinkButton;
link.label= "Pa.Vijay";
link.width=100;
link.height=25;
link.x=50;
link.y=50;
this.addChild(link);
link.addEventListener(MouseEvent.CLICK,showimage);
}
public function showimage(event:MouseEvent):void{
image1=new Image;
image1.source="../Assets/Pa.Vijay.jpg";
image1.maintainAspectRatio=false;
image1.width=50;
image1.height=50;
image1.x=60;
image1.y=80;
this.addChild(image1);
}
]]>
</mx:Script>
</mx:Application>

Screenshots:

First screen

If you run the source code in Flex Builder, You will see this kind of screen.

If you click that linkbutton named Pa.Vijay, his image will be displayed.

If you click that linkbutton named Pa.Vijay, his image will be displayed.

Thanks & Regards,
Kasi Ruby.R

Advertisement

Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.

Follow

Get every new post delivered to your Inbox.