开发者

why is ExternalInterface available inside Flash ide

开发者 https://www.devze.com 2022-12-15 21:02 出处:网络
hey I\'m trying to build this simple debugger class so i can see flash vars inside the browser console and if I\'m testing it inside the flash ide i will get the good old tracer. But for some reason E

hey I'm trying to build this simple debugger class so i can see flash vars inside the browser console and if I'm testing it inside the flash ide i will get the good old tracer. But for some reason ExternalInterface.available returns true inside the Flash ide!?

package libs
{
    import flash.external.ExternalInterface;

    public class debug
    {
        public function tracer(variable:*):void
        {
            if(ExternalInterface.available)
            {
                if(variable is String)
              开发者_如何学Go  {
                    variable = '"'+variable+'"';
                }
                ExternalInterface.call('console.log(' + variable + ')');
            }
            else
            {
                trace(variable);
            }   
        }
    }
}


You can use flash.system.Capabilities.playerType to determine whether you're in the flash ide or not...

import flash.system.Capabilities;

if (Capabilities.playerType == 'External')
  trace("you're in the ide");
else
  trace("you're not in the ide");


Awesome, I gotta play with that.

The reason why you get true, if you're using Flash CS4 is because the Stage inside the IDE is a SWF running, and 3d stuff and bones are calls from the IDE to the stage swf using ExternalInterface.

Would be cool to hack that! Thanks, George

0

精彩评论

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

关注公众号