开发者

Get the names of variables from a web-page?

Is there a way to get the names of variables from a flash game? I have been playing with my players health with the code;

javascript:document.embeds[0].SetVariable("_root.player.intHP", 0)

I am looking for a way to find out the rest of the variables, like damage and such. Th开发者_JAVA百科anks in advance


You need to use the ExternalInterface API in Flash. It will map a function inside of Flash to a be accessible through the interface.

AS3 - map an internal function to a js function

import flash.external.ExternalInterface;
if (ExternalInterface.available) 
    ExternalInterface.addCallback("getMyVar", sendMyVar);

function(){
  return myFlashVar;
}

JS - call the function name on the external interface

var jsMyVar = myFlashMovie.getMyVar();

You can also pass params to set information as well but need to add it in the Flash Movie.

If you dont have access to the Flash code you can't bridge between JS and As3.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜