我在 ActionScript 移动项目上工作,我正在使用带有 AS3 的八哥,我尝试添加事件侦听器以检测八哥类中的 ORIENTATION_CHANGE 事件但它不会检测到更改,如果我在 AS3 类(主类)中添加事件侦听器将检测并再次调用八哥类。
AS3的主要类别:
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.StageOrientationEvent;
import starling.core.Starling;
public class mainClass extends Sprite
{
private var myStarling:Starling;
public function mainClass()
{
super();
stage.addEventListener(Event.RESIZE,onResize);
stage.addEventListener(flash.events.StageOrientationEvent.ORIENTATION_CHANGE,shangedOr);
}
private function shangedOr(e:StageOrientationEvent):void
{
// code
}
private function onResize(e:Event):void
{
myStarling = new Starling(Main,stage);
myStarling.start();
}
}
}
八哥类:我添加了新的 AS 类并使其成为八哥类
package
{
import feathers.controls.ScrollContainer;
import feathers.layout.VerticalLayout;
import feathers.themes.AeonDesktopTheme;
import flash.events.Event;
import feathers.controls.Label;
import feathers.controls.TextInput;
import flash.events.StageOrientationEvent;
import org.osmf.layout.VerticalAlign;
import starling.display.DisplayObject;
import starling.display.Sprite;
import starling.display.Stage;
import starling.events.Event;
public class starlingClass extends starling.display.Sprite
{
private var newLayout:VerticalLayout = new VerticalLayout();
private var container:ScrollContainer = new ScrollContainer();
public function starlingClass()
{
super();
this.addEventListener(starling.events.Event.ADDED_TO_STAGE,addToStage);
this.addEventListener(flash.events.StageOrientationEvent.ORIENTATION_CHANGING,orientationChange);
}
private function addToStage(e:starling.events.Event):void
{
this.theme = new AeonDesktopTheme( this.stage );
drawComponent();
}
private function orientationChange(evt:StageOrientationEvent):void
{
// orientation will not responce to change orientation.
}
private function drawComponent():void
{
var button:feathers.controls.Button = new feathers.controls.Button();
button.label = "Click Me";
var newLabel:Label = new Label();
newLabel.text = "hello world";
var txt:TextInput = new TextInput();
var layout:VerticalLayout = new VerticalLayout();
var container:ScrollContainer = new ScrollContainer();
container.layout = layout;
container.addChild(button);
container.addChild(newLabel);
container.addChild(txt);
this.addChild( container );
layout.paddingTop = 10;
layout.paddingRight = 15;
layout.paddingBottom = 10;
layout.paddingLeft = 15;
layout.gap = 5;
}
}
}
问题:mainClass.as
将检测到方向变化并调用starlingClass.as
并且不显示任何组件。starlingClass.as
永远不会检测到方向变化可能是因为我在八哥类中检测到一个闪光事件..任何帮助