首先在fb3中拖入两个button 和一个Panel :
代码如下
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="350" height="200" layout="absolute">
<mx:Panel title="Having Fun with Cursors" x="0" y="0" width="100%" height="100%" layout="absolute">
<mx:Button label="Show Cursor" x="10" y="59" width="115"/>
<mx:Button label="Remove Cursor" x="205" y="59" width="115"/>
</mx:Panel>
下面为这两个分别增加单击事件分别是showCursor 和 removeCursor:
<mx:Button label="Show Cursor" click="showCursor()" x="10" y="59" width="115"/><mx:Button label="Remove Cursor" click="removeCursor()" x="205" y="59" width="115"/>
下面就添加as3 code吧 ! 一个Script 标签 和 给这个Cursor添加函数
<mx:Script>
<![CDATA[
import mx.managers.CursorManagerPriority;
import mx.managers.CursorManager;
[Embed("/cursors/cc.png")]
private var customCursor:Class;
private function showCursor():void {
CursorManager.setCursor( customCursor, CursorManagerPriority.HIGH, 3, 2);
}
private function removeCursor():void {
CursorManager.removeAllCursors();
}
]]>
</mx:Script>
好 ~ 一个自定义的Cursor完成拉 可以造出自己喜欢的Cursor拉!
代码如下
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="350" height="200" layout="absolute">
<mx:Panel title="Having Fun with Cursors" x="0" y="0" width="100%" height="100%" layout="absolute">
<mx:Button label="Show Cursor" x="10" y="59" width="115"/>
<mx:Button label="Remove Cursor" x="205" y="59" width="115"/>
</mx:Panel>
下面为这两个分别增加单击事件分别是showCursor 和 removeCursor:
<mx:Button label="Show Cursor" click="showCursor()" x="10" y="59" width="115"/><mx:Button label="Remove Cursor" click="removeCursor()" x="205" y="59" width="115"/>
下面就添加as3 code吧 ! 一个Script 标签 和 给这个Cursor添加函数
<mx:Script>
<![CDATA[
import mx.managers.CursorManagerPriority;
import mx.managers.CursorManager;
[Embed("/cursors/cc.png")]
private var customCursor:Class;
private function showCursor():void {
CursorManager.setCursor( customCursor, CursorManagerPriority.HIGH, 3, 2);
}
private function removeCursor():void {
CursorManager.removeAllCursors();
}
]]>
</mx:Script>
好 ~ 一个自定义的Cursor完成拉 可以造出自己喜欢的Cursor拉!
本文介绍如何使用Adobe Flex创建自定义光标。通过拖放Button和Panel组件,并编写AS3代码来显示和移除自定义光标。
739

被折叠的 条评论
为什么被折叠?



