Reflect.setProperty() error 1056

#1

Hello,

I have an error 1056 on flash target with Reflect.setProperty()
impossible to create test property on DocumentClass

import openfl.display.Sprite;

class Main extends Sprite
{
    public function new()
    {
        super();
	    
	    Reflect.setProperty(this, "test", true);
    }
}

Thanks

0 Likes

#2

Why would you want to do that anyway? Seems like there’s probably a better / more strictly typed solution to whatever you’re trying to do.

0 Likes

#3

I tried to create a typed variable but hasOwnProperty() not exist in OpenFl ?

0 Likes

#4

We implement hasOwnProperty in openfl.utils.Object

I think you can add fields using Reflect.setField, but beware, this makes objects dynamic and reduces performance

0 Likes