Rewrite flash native methods and classes

Hey!

I’m new to the bbs, and I saw a few questions asking stuff similar to what I’m doing so I was hoping someone could help me :).

I am trying to do an app that requires me to change the behavior of a few native methods and classes of a an application.

I want to override methods such as:

ExternalInterface.call, ExternalInterface.addCallback, flash.net.navigateToURL in a loaded movie.

There are a few ways to do this for example:

  1. Getting the SWF’s bytecode and decompile it. Then change the symbols table with my own class.

  2. Loading the other movie in my applicationDomain, by doing so, I would be able to rewrite it’s own classes.

To do (2) what I did was:

  1. Turn off the “-strict” flag.
  2. Turn on the “-es” flag.

in the compiler and then do something like:

flash.net.navigateToURL = function(u:URLRequest,window:String):void {
  throw new Error("yay it works");
}
flash.net.navigateToURL(new URLRequest("http://www"), "1");

which throws no errors at compile time, but when I execute it, I receive:

ReferenceError: Error #1056: Cannot create property flash.net::navigateToURL on global.
	at Main/init()
	at Main()

Which I sense means that I can’t override anything under “flash”. Anybody knows how to do this?

Thanks for your time! :slight_smile: