<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" horizontalAlign="left"
mouseMove="onMouseMove(event)"
mouseDown="onMouseDown(event)">
<mx:Script><![CDATA[
//tests mousedown to see if it is over Web Access button
private var giMouseXLast:Number = 0;
private var giMouseYLast:Number = 0;
private function onMouseDown(oEvent:Object):Void
{
var iMouseX:Number = oEvent.target.mouseX;
var iMouseY:Number = oEvent.target.mouseY;
if
(iMouseX > 200 && iMouseX < 400 && iMouseY >
100 && iMouseY <200) { //mousedown is over magic spot
alert("You hit the magic spot");
}
lblLastMouseDownCoord.text = "(" + iMouseX + "," + iMouseY + ")"
}
//sets global variables when mouse moves
private function onMouseMove(oEvent:Object):Void
{
giMouseXLast = oEvent.target.mouseX;
giMouseYLast = oEvent.target.mouseY;
}
]]></mx:Script>
<mx:HBox>
<mx:Label id="lblLastMouseDown" text="Last Mouse Down" color="#FFFFFF" fontSize="18" />
<mx:Label id="lblLastMouseDownCoord" text="" color="#FFFFFF" fontSize="18" />
</mx:HBox>
<mx:HBox>
<mx:Label id="lblCurMousePos" text="Current Mouse Position" color="#FFFFFF" fontSize="18" />
<mx:Label id="lblCurMousePosCoord"
text='{"(" + giMouseXLast + "," + giMouseYLast + ")"}'
color="#FFFFFF" fontSize="18" />
</mx:HBox>
</mx:Application>
Wednesday, October 24, 2012
Friday, October 12, 2012
Displaying icons in a Flex PopUpButton control
<?xml version="1.0"?> <!-- http://blog.flexexamples.com/2008/01/24/displaying-icons-in-a-flex-popupbutton-control/ --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" verticalAlign="top" backgroundColor="white"> <mx:Script> <![CDATA[ import mx.controls.Menu; [Bindable] private var menu:Menu; private function initMenu():void { menu = new Menu(); menu.dataProvider = arr; } ]]> </mx:Script> <mx:Style> PopUpButton { popUpStyleName: myCustomPopUpStyleName; } .myCustomPopUpStyleName { fontWeight: normal; textAlign: left; } </mx:Style> <mx:Array id="arr"> <mx:Object label="Alert" /> <mx:Object label="Button" icon="@Embed('assets/Button.png')" /> <mx:Object label="ButtonBar" icon="@Embed('assets/ButtonBar.png')" /> <mx:Object label="CheckBox" icon="@Embed('assets/CheckBox.png')" /> <mx:Object label="ColorPicker" icon="@Embed('assets/ColorPicker.png')" /> </mx:Array> <mx:PopUpButton id="popUpButton" label="Select a control..." popUp="{menu}" preinitialize="initMenu();" creationComplete="popUpButton.open();" /> </mx:Application>
Subscribe to:
Posts (Atom)