<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
xmlns:buttons="com.renaun.buttons.*"
initialize="createRollOvers()" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import mx.controls.Image;
import mx.controls.Button;
[Bindable]
[Embed("images/arrowBlueUp.png")]
private var iconUp:Class;
[Bindable]
[Embed("images/arrowBlueDown.png")]
private var iconOver:Class;
[Bindable]
[Embed("images/arrowGreenDown.png")]
private var iconDown:Class;
private function createRollOvers():void {
var lblImgRoll:Label = new Label();
lblImgRoll.text = "Image Roll Over using ActionScript";
pnlRollover.addChild( lblImgRoll );
var imgRoll:Image = new Image();
imgRoll.source = iconUp;
imgRoll.addEventListener( MouseEvent.ROLL_OVER, imgRollOver );
imgRoll.addEventListener( MouseEvent.ROLL_OUT, imgRollOut );
imgRoll.addEventListener( MouseEvent.MOUSE_DOWN, imgRollDown );
pnlRollover.addChild( imgRoll );
var lblBtnRoll:Label = new Label();
lblBtnRoll.text = "Button Roll Over using ActionScript";
pnlRollover.addChild( lblBtnRoll );
var btnRoll:Button = new Button();
btnRoll.width = 20;
btnRoll.height = 20;
btnRoll.setStyle( "fillAlphas", [0.0,0.0] );
btnRoll.setStyle( "highlightAlphas", [0.0,0.0] );
btnRoll.setStyle( "upSkin", null );
btnRoll.setStyle( "overSkin", null );
btnRoll.setStyle( "downSkin", null );
btnRoll.setStyle("overIcon",iconOver);
btnRoll.setStyle("downIcon",iconDown);
btnRoll.setStyle("upIcon",iconUp);
pnlRollover.addChild( btnRoll );
}
private function imgRollOver( event:MouseEvent ):void {
event.target.source = iconOver;
}
private function imgRollOut( event:MouseEvent ):void {
event.target.source = iconUp;
}
private function imgRollDown( event:MouseEvent ):void {
event.target.source = iconDown;
}
]]>
</mx:Script>
<mx:Panel id="pnlRollover" title="Roll Over Image/Button Examples"
horizontalAlign="center" verticalAlign="middle"
width="300"
height="250"
layout="vertical" >
<mx:Label text="Custom Roll Over Image" />
<buttons:RollOverImage upImage="{ iconUp }" overImage="{ iconOver }" downImage="{ iconDown }" />
<mx:ControlBar>
<mx:Label text="Right Click to View Source" />
</mx:ControlBar>
</mx:Panel>
</mx:Application>