Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 失去对TLF文本的关注_Actionscript 3_Flash - Fatal编程技术网

Actionscript 3 失去对TLF文本的关注

Actionscript 3 失去对TLF文本的关注,actionscript-3,flash,Actionscript 3,Flash,我已将SWF文件嵌入到HTML中。我在我的AS3应用程序中为聊天室使用了TLF文本,但问题是,当我切换到其他页面并重新打开我的应用程序时,应用程序失去了对TLF文本的关注。请注意,当我在桌面上使用flash player运行SWF文件时,我不会遇到这个问题 我尝试使用以下代码重新关注TLF文本,但在我的案例中不起作用 addEventListener(Event.ACTIVATE, infocus); function infocus(e:Event):void { myTLF.text

我已将SWF文件嵌入到HTML中。我在我的AS3应用程序中为聊天室使用了TLF文本,但问题是,当我切换到其他页面并重新打开我的应用程序时,应用程序失去了对TLF文本的关注。请注意,当我在桌面上使用flash player运行SWF文件时,我不会遇到这个问题

我尝试使用以下代码重新关注TLF文本,但在我的案例中不起作用

addEventListener(Event.ACTIVATE, infocus);
function infocus(e:Event):void {
    myTLF.textFlow.interactionManager = new EditManager();
    myTLF.textFlow.interactionManager.selectRange(myTLF.text.length, myTLF.text.length);
    myTLF.textFlow.interactionManager.setFocus();
}

我的问题是我们如何解决这个问题?因为每次切换到其他页面时,人们都要点击聊天框,这真的让人很烦恼。

这样做的方法很少。您可以通过以下方式手动将焦点放在所需对象上:

  • 在舞台上收听MouseEvent.ROLL_,制作一个将焦点返回到文本字段的处理程序
  • 如果您想将焦点返回到切换回页面,则需要编写一个JS脚本,通过ExternalInterface告诉SWF将焦点放在文本字段上