开发者

Flash AS3 Root Document Linking

Hi I have a main document/fla, and ive created a game class, instantiated it in the document/fla file and it runs now i want to put a button inside that game class that can tell the root document/fla to jump to a certain frame. How 开发者_如何学Cwould i go about this?

Thanks


Your game class could dispatch an event (GameEvent.SUPER_ACTION). Then in your fla :

var targetFrame:int=10;
var game:Game = new Game();
game.addEventListener(GameEvent.SUPER_ACTION,gameSuperAction);

function gameSuperAction(e:GameEvent):void{
    gotoAndStop(targetFrame);
}

or if the game's button is public :

var targetFrame:int=10;
var game:Game = new Game();
game.button.addEventListener(MouseEvent.CLICK,gameButtonClick);

function gameButtonClick(e:MouseEvent):void{
    gotoAndStop(targetFrame);
}

Here is an AS3 event flow example : http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e53.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜