Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.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 cs6的charCode是否有取代基?_Actionscript 3_Flash_Flash Cs6 - Fatal编程技术网

Actionscript 3 cs6的charCode是否有取代基?

Actionscript 3 cs6的charCode是否有取代基?,actionscript-3,flash,flash-cs6,Actionscript 3,Flash,Flash Cs6,我正在尝试使用actionscript3来尝试使用一个变量来播放单独的动画,但它在flash cs6中不起作用,我的学校不会更新它 我曾尝试在变量的上下文中使用它,但它总是发出错误消息: var currentDirection = event.charCode; Scene 1, Layer 'Sprite', Frame 1, Line 10 1120:Access of undefined property event 也许有帮助的是一个完整的示例,其中显示了AS3中完成此任务所需的

我正在尝试使用
actionscript3
来尝试使用一个变量来播放单独的动画,但它在
flash cs6
中不起作用,我的学校不会更新它

我曾尝试在变量的上下文中使用它,但它总是发出错误消息:

var currentDirection = event.charCode;

Scene 1, Layer 'Sprite', Frame 1, Line 10  1120:Access of undefined property event

也许有帮助的是一个完整的示例,其中显示了AS3中完成此任务所需的所有代码:

import flash.events.KeyboardEvent;

//var to hold the last key pressed. 
var currentDirection:int = -1; 

//listen for the key down event, when it happens, call the onKeyDown function below
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);

//this function runs whenever a key goes down
function onKeyDown(event:KeyboardEvent) {
    currentDirection = event.charCode; //assign the var the current key press char code
    trace(event.charCode); //trace to the output panel to see if it's working
}

没有提供足够的信息。您是否
导入flash.events.*在您的代码中?这条线为什么存在<代码>var currentDirection=event.charCodevar currentDirection:int=event.keyCode我没有添加导入
flash.events.*
i只添加了
flash.events.keyboard
flash.events.mouse
var currentDirection=event.charCode存在,因为我试图把int作为一个变量来引用它,之后它试图记录最后一个被按下的键并添加更多内容。另外,keycode也没有帮助,因为我需要一些东西来保留最后按下的键,所以您提供的代码对我没有多大帮助。我真正想要的是(keycodes),但在cs6中,我认为可能的键可能在问题VC中。有人问,“它在事件处理函数中吗?”我看不到它周围的其他代码,所以我主要是猜测,但基于这个错误,我觉得答案可能是“不”。如果是这种情况,可能导致错误的原因是试图访问它,或者超出范围,或者在实际按下任何键之前(在这两种情况下,“事件”对象都不存在,因此未定义)。