Search Flex Samples

Setting a Button control’s icon to an asset from a SWF file in Flex




<?xml version="1.0" encoding="utf-8"?>


<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

layout="horizontal"

verticalAlign="middle"

backgroundColor="white"

creationComplete="init();">



<mx:Script>

<![CDATA[

import mx.controls.Button;



[Embed("icons.swf#bullet_add")]

public var bulletAddIcon:Class;



[Embed("icons.swf#bullet_delete")]

public var bulletDeleteIcon:Class;



[Embed("icons.swf#bullet_star")]

public var bulletStarIcon:Class;



private var addButton:Button;

private var deleteButton:Button;

private var starButton:Button;



private function init():void {

// Add

addButton = new Button();

addButton.label = "Bullet Add";

addButton.setStyle("icon", bulletAddIcon);

addChild(addButton);

// Delete

deleteButton = new Button();

deleteButton.label = "Bullet Delete";

deleteButton.setStyle("icon", bulletDeleteIcon);

addChild(deleteButton);

// Star

starButton = new Button();

starButton.label = "Bullet Star";

starButton.setStyle("icon", bulletStarIcon);

addChild(starButton);

}

]]>

</mx:Script>



</mx:Application>

0 comments:

Related Flex Samples

Learn Flex: Flex Samples | Flex Video Tutorials Flex Examples