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
精彩评论