从Flash发送数据德裕类 [英] Send data from Flash to Starling class

查看:110
本文介绍了从Flash发送数据德裕类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从mainClass(闪存类),将数据发送到我的八哥类。下面是两个类的code。我需要在它们之间传递数据。

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和八哥之间的数据?我创建了一个事件类从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 并调用它,当你的实例准备(在 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发送数据德裕类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆