将数据从 Flash 发送到 Starling 类 [英] Send data from Flash to Starling class
问题描述
我想将数据从 mainClass(Flash 类)发送到我的 Starling 类.这是两个类的代码.我需要在它们之间传递数据.
I want to send data from mainClass (Flash class) to my Starling class. Here is the code of two classes. I need to pass data between them.
package
{
import flash.display.Sprite;
import flash.events.Event;
public class mainClass extends Sprite
{
private var myStarling:Starling;
public function mainClass ()
{
super();
stage.addEventListener(Event.RESIZE,onResize);
}
private function shangedOr(e:StageOrientationEvent):void
{
// code
}
private function onResize(e:Event):void
{
myStarling = new Starling(Main,stage);
myStarling.start();
}
}
}
Main.as 类八哥:
Main.as class of starling :
package
{
import starling.core.Starling;
import starling.display.Sprite;
public class Main extends starling.display.Sprite
{
private var theme:AeonDesktopTheme;
public function Main()
{
super();
this.addEventListener(starling.events.Event.ADDED_TO_STAGE,addToStage);
}
private function addToStage(e:starling.events.Event):void
{
this.theme = new AeonDesktopTheme( this.stage );
drawComponent();
}
private function drawComponent():void
{
//code
}
}
}
有没有办法在 Flash 和 Starling 之间传递数据?我创建了一个事件类来监听 Flash,然后从 Starling 类调度以从 Flash 类中获取我需要的数据,但它不起作用.
Is there a way to pass data between Flash and Starling? I created an Event class to listen from Flash, then dispatch from Starling class to get the data I need from the Flash class but it didn't work.
推荐答案
快速解决方案,在某些情况下很有用:在 mainClass
中创建 static
函数,并在 mainClass
中调用它code>Main 实例已准备就绪(例如在 addToStage
中)
Fast solution , useful in some cases: make static
function in mainClass
and call it when your Main
instance is ready (in addToStage
for example)
这篇关于将数据从 Flash 发送到 Starling 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!