我是否知道如何解决在需要将.as文件导入main.mxml文件时发生的错误? .as文件使用stagevideo函数,输出显示在AIR窗口中。我可以知道我错过了哪一部分吗?谢谢,如果有人能帮助我,我感谢你。 谢谢
<fx:Script>
<![CDATA[
import flash.display.StageDisplayState;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import mx.events.FlexEvent;
import Video.SimpleVid;
public var simpleVid:SimpleVid;
protected function init():void
{
simpleVid = new SimpleVid();
addElement(simpleVid);
stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown);
}
public function onKeyDown(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.O)
{
if(simpleVid.available)
simpleVid.toggleStageVideo(simpleVid.inited=!simpleVid.inited);
}
else if ( event.keyCode == Keyboard.F )
{
simpleVid.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
}
else if ( event.keyCode == Keyboard.SPACE )
{
simpleVid.ns.togglePause();
}
else if(event.keyCode == Keyboard.H)
{
var matrix:Matrix =simpleVid.stage.transform.matrix;
matrix.scale(-1,1);
matrix.translate(stage.width,0);
simpleVid.stage.transform.matrix=matrix;
}
else if(event.keyCode == Keyboard.R)
{
simpleVid.ns.resume();
}
}
]]>
</fx:Script>
错误显示stage.addEventListener(keyboardEvent.KEY_DOWN,onKeyDown); simpleVid是simpleVid.as文件的名称,我将其导入main.mxml文件。
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:Video = "Video.*"
backgroundAlpha="0"
creationComplete="init()"
backgroundColor="#000000">
答案 0 :(得分:0)
你可以通过使用获得舞台
systemManager.stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown);