Skip to content

Instantly share code, notes, and snippets.

@bmfs
Forked from anonymous/BaseTest.as
Created February 12, 2016 13:27
Show Gist options
  • Save bmfs/78adda236fe2c6361bea to your computer and use it in GitHub Desktop.
Save bmfs/78adda236fe2c6361bea to your computer and use it in GitHub Desktop.
as3 calling overrided function super, makes function public
package {
import haxe.Log;
public class BaseTest {
public function BaseTest() : void {
}
protected function functionToOverride() : void {
(haxe.Log._trace)("BaseTest::functionToOverride",{ fileName : "Main.hx", lineNumber : 10, className : "BaseTest", methodName : "functionToOverride"});
}
public function functionToOverride2() : void {
(haxe.Log._trace)("BaseTest::functionToOverride2",{ fileName : "Main.hx", lineNumber : 15, className : "BaseTest", methodName : "functionToOverride2"});
}
}
}
package;
class BaseTest
{
public function new(){
}
function functionToOverride()
{
trace("BaseTest::functionToOverride");
}
function functionToOverride2()
{
trace("BaseTest::functionToOverride2");
}
}
class Test extends BaseTest
{
public function new(){
super();
}
override function functionToOverride()
{
trace("Test::functionToOverride");
}
override function functionToOverride2()
{
trace("Test::functionToOverride");
super.functionToOverride2();
}
public function doSomething()
{
functionToOverride();
functionToOverride2();
}
}
class Main {
public static function main()
{
var t = new Test();
t.doSomething();
}
}
package {
import haxe.Log;
import flash.Boot;
public class Test extends BaseTest {
public function Test() : void { if( !flash.Boot.skip_constructor ) {
super();
}}
protected override function functionToOverride() : void {
(haxe.Log._trace)("Test::functionToOverride",{ fileName : "Main.hx", lineNumber : 27, className : "Test", methodName : "functionToOverride"});
}
protected override function functionToOverride2() : void {
(haxe.Log._trace)("Test::functionToOverride",{ fileName : "Main.hx", lineNumber : 32, className : "Test", methodName : "functionToOverride2"});
super.functionToOverride2();
}
public function doSomething() : void {
this.functionToOverride();
this.functionToOverride2();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment