- <?xml version="1.0" encoding="utf-8"?>
- <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768">
- <fx:Script>
- <![CDATA[
- import mx.core.BitmapAsset;
- // 自定義的鼠標元素
- var myCursor:Sprite = new Sprite();
- protected function button1_clickHandler(event:MouseEvent):void
- {
- // 嵌入圖像元數據
- [Embed(source = "1222.png")]
- var cur1:Class;
- // 把圖片設置到本身的鼠標元素上去
- var cursorStyle1:BitmapAsset = new cur1() as BitmapAsset;
- myCursor.addChild(cursorStyle1);
- // 添加stage的mousemove監聽器
- stage.addEventListener(MouseEvent.MOUSE_MOVE, mousemoveHandler);
- // 添加sprite對象並隱藏鼠標
- stage.addChild(myCursor);
- Mouse.hide();
- }
- // 監聽函數
- protected function mousemoveHandler(event:MouseEvent):void
- {
- myCursor.x = event.stageX;
- myCursor.y = event.stageY;
- }
- ]]>
- </fx:Script>
- <s:Button x="274" y="177" label="按鈕" click="button1_clickHandler(event)"/>
- </s:Application>