Send data from Flash to Starling class

北城余情 提交于 2019-12-01 23:21:54

问题


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 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
    }

}
}

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.


回答1:


Fast solution , useful in some cases: make static function in mainClass and call it when your Main instance is ready (in addToStage for example)




回答2:


definately we can't write any event or class to interact with flash and starling for this issue we can use CALL_BACK Function. so that you can interact or send data from core flash to starling and starling to core flash. Function call won't give any error.



来源:https://stackoverflow.com/questions/16441734/send-data-from-flash-to-starling-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!