swc and swf-protected or @:protected

28 views
Skip to first unread message

mihail.r...@integra-games.com

unread,
May 5, 2016, 10:43:32 AM5/5/16
to Haxe
Hi ! I Have strange problem. I want to compile swc with flash "protected" variables and methods. But if set swf-protected flag or add @:protected metatag haxe compile bad SWC.

For static protected methods i get error "Error #1006: Foo is not a function." Protected vars becomes very strange. They like become static vars (have same value for all instances), debuger says that this var is null, but getter works (again - return one "last" value for all instances. I use Haxe 3.2.1. Compiler parameters are:
-main HaxeMain
--flash-strict
--macro include('my.package', true)
-cp haxe_src/
-D fdb 
-debug
-D dump=pretty
-swf libs/engine_debug.swc


I have very simple code like:

class ObjectType {
 @:protected var _name:String;

    public function new(pName:String){
        this._name  = pName;
    }

    public var name(get, never):String;
    private function get_name():String {
        return _name;
    }
}


Than i incude SWC and try:

haxe.initSwc(this as MovieClip);
var type1:ObjectType  = new ObjectType("TYPE_1");
var type2:ObjectType  = new ObjectType("TYPE_2");

trace(type1.get_name());
trace(type2.get_name());

Output:
TYPE_2
TYPE_2

If i change @:protected to public - all works fine !!!


What i am doing wrong ? It is bug of Haxe ?
Reply all
Reply to author
Forward
0 new messages