How to access top level package in ActionScript?

拥有回忆 提交于 2019-12-05 14:31:33

trace is in the public namespace so it could be reached calling public::trace , however here the problem is that you are redefining another public trace, so you can't call the previous one.

What you can do is :

1 - if your method trace have not to be public made it protected or private and then you will be able to call the original trace:

public class Main extends Sprite 
{
    protected function trace(...args):void {
        public::trace(args) // access to the public function trace
    }
    public function Main():void 
    {
        trace("hello world")
    }       
}

2 - if you can't change the signature assign the original trace into a static var/const so you can use it later :

public class Main extends Sprite 
{
    // here save the original trace function
    private static const _trace:Function = trace

    public function trace(...args):void {
        _trace(args) // call the original trace
    }
    public function Main():void 
    {
        trace("hello world")
    }       
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!