May I know how to solve the error that occur when need to import .as file into main.mxml file ? the .as file is using stagevideo function, the output is display in AIR window. May I know which part I miss up? Thank you and I appreciate if there are anyone able to help me. Thank you
<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>
The error show that the stage.addEventListener(keyboardEvent.KEY_DOWN, onKeyDown); The simpleVid is the name of simpleVid.as file, that I import into the main.mxml file.
<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">
You can get stage by using
systemManager.stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown);