gpt4 book ai didi

actionscript-3 - 如何检测光标何时在 AS3 中变为 I 型梁?

转载 作者:行者123 更新时间:2023-12-04 06:40:18 24 4
gpt4 key购买 nike

我的 Flash 项目中有一个自定义光标。默认情况下,当您将鼠标悬停在文本字段上时,自定义光标保持可见,并且同时显示 I 型光标和自定义光标。为了避免这种情况,我需要在 I 形光标出现时隐藏我的自定义光标(即当您将鼠标悬停在文本字段上时)。此外,光标始终设置为 MouseCursor.AUTO 状态。那么我怎样才能检测到它何时变为工字梁呢?
提前致谢

最佳答案

这是尝试模仿您想要的东西的东西,它向舞台添加了一个事件监听器,并检测文本字段上是否发生翻转/退出事件并相应地更改光标:

package 
{
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.ui.Mouse;
import flash.ui.MouseCursor;

public class Main extends Sprite
{

private var textField1:TextField = new TextField();
private var textField2:TextField = new TextField();

public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}

private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point

var loader:Loader = new Loader();
loader.load(new URLRequest('bg.png'));
addChild(loader);

textField1.text = "Text Field 1";
textField1.border = true;
textField1.x = 100;
addChild(textField1);

textField2.text = "Text Field 2";
textField2.border = true;
textField1.x = 400;
addChild(textField2);

Mouse.cursor = MouseCursor.HAND;

stage.addEventListener(MouseEvent.ROLL_OVER, onRollOver, true);
stage.addEventListener(MouseEvent.ROLL_OUT, onRollOut, true);
}

private function onRollOver(e:MouseEvent):void
{
var tf:TextField = e.target as TextField;
if (tf)
{
Mouse.cursor = MouseCursor.IBEAM;
//hide your custom cursor here
}
}

private function onRollOut(e:MouseEvent):void
{
var tf:TextField = e.target as TextField;
if (tf)
{
Mouse.cursor = MouseCursor.HAND;
//show your custom cursor here
}
}
}

}

关于actionscript-3 - 如何检测光标何时在 AS3 中变为 I 型梁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15191948/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com