Actionscript 3 AS3-在白板中创建文本字段
我必须在Flash动作脚本3中创建一个白板。。我无法在白框中创建文本框属性。当我打开swf时,我需要一个文本框属性,我可以在用户希望的地方创建一个文本框字段。请帮个忙。像这样的事 白板Actionscript 3 AS3-在白板中创建文本字段,actionscript-3,actionscript,Actionscript 3,Actionscript,我必须在Flash动作脚本3中创建一个白板。。我无法在白框中创建文本框属性。当我打开swf时,我需要一个文本框属性,我可以在用户希望的地方创建一个文本框字段。请帮个忙。像这样的事 白板 package { import flash.display.Sprite; import flash.events.MouseEvent; import flash.text.TextField; import flash.text.TextFieldAutoSize;
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFieldType;
public class Whiteboard extends Sprite
{
private var _whiteboard : Sprite;
private var _currentText : TextBox;
public function Whiteboard()
{
super();
createWhiteboard();
enableUserInput();
}
private function createWhiteboard() : void
{
// create whiteboard sprite
_whiteboard = new Sprite();
// add to displaylist
addChild(_whiteboard);
// draw graphics
with(_whiteboard.graphics)
{
lineStyle(10, 0x666666, 1);
beginFill(0xFFFFFF, 1);
drawRect(0, 0, 800, 600);
endFill();
}
}
private function enableUserInput() : void
{
_whiteboard.addEventListener(MouseEvent.CLICK, onUserInteract);
}
private function onUserInteract(event : MouseEvent) : void
{
// remove if empty
if(_currentText && _currentText.htmlText.length == 0)
{
// remove from displaylist
_whiteboard.removeChild(_currentText);
}
// add new
if(event.target == _whiteboard)
{
_currentText = new TextBox();
_currentText.x = event.stageX;
_currentText.y = event.stageY;
// add to displaylist
_whiteboard.addChild(_currentText);
}
else
{
// use clicked text
_currentText = event.target as TextBox;
}
// set selection
_currentText.setSelection(0, _currentText.htmlText.length);
// set focus
stage.focus = _currentText;
}
}
}
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFieldType;
import flash.text.TextFormat;
class TextBox extends TextField
{
function TextBox()
{
super();
background = true;
backgroundColor = 0xFF88FF;
multiline = false;
autoSize = TextFieldAutoSize.LEFT;
type = TextFieldType.INPUT;
htmlText = "";
selectable = true;
defaultTextFormat = new TextFormat("_sans", 18, 0xFFFFFF);
}
}
您的意思是用户需要能够单击某个位置并显示文本框吗?是的。实际上,当用户选择图标,然后单击某个位置时,会出现一个文本框。。我可以自己尝试图标部分。你能更具体一点吗?我只需要一个白板,当用户点击swf文件时,一个文本框必须打开。。他可以在里面输入他的文字经过很长时间的尝试。。当我发布这个问题时,我还是个初学者。接受此提示,因为这是必需的提示。。