Overriding native method names and class names
@author 9re
it is possible to override native method names
and class names but impossible to override package names
♥0 |
Line 56 |
Modified 2009-10-13 21:38:31 |
MIT License
archived:2017-03-30 10:11:35
ActionScript3 source code
/**
* Copyright 9re ( http://wonderfl.net/user/9re )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/5Hzl
*/
package
{
import flash.display.Sprite;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.external.ExternalInterface;
/**
* @author 9re
*
* it is possible to override native method names
* and class names but impossible to override package names
*/
public class Test extends Sprite
{
public function Test()
{
addChild(new SuperClass);
}
}
}
import flash.net.URLRequest;
import flash.text.TextField;
import flash.display.Sprite;
import flash.net.navigateToURL;
import flash.external.ExternalInterface;
class ExternalInterface {
static public function call(functionName:String, ... arguments):* {
throw new Error("internal class");
}
}
class BaseClass extends Sprite {
public var ExternalInterface:Object = { };
private var tf:TextField;
public function BaseClass () {
tf = new TextField();
tf.width = 465;
tf.height = 465;
tf.mouseEnabled = false;
tf.selectable = false;
addChild(tf);
ExternalInterface.call = function (functionName:String, ... arguments):* {
tf.appendText("\nExternalInterface.call: " + functionName );
return null;
};
//flash.net.navigateToURL = navigateToURL;
}
public var flash:Object = {
net : {
navigateToURL : function (request:URLRequest, window:String = null):void {
tf.appendText("flash.net.navigateToURL: " + request.url);
}
}
}
public var navigateToURL:Function = function (request:URLRequest, window:String = null):void {
tf.appendText("navigateToURL: " + request.url);
}
}
class SuperClass extends BaseClass {
public function SuperClass() {
navigateToURL(new URLRequest("http://www.google.com/"), "_blank");
ExternalInterface.call("console.log", "Hello, world!");
//flash.net.navigateToURL(new URLRequest("http://www.yahoo.co.jp"), "_blank");
}
}