Object __get method problem

Hi, how can i explain it with my bad english i dont know. So i am writing the code.

var bmp:Bitmap=new Bitmap(BitmapData.fromFile("img/ball.png"));
var h:Object = {};
h.__set("bitmap", bmp);
h.__get("bitmap").x=10;//dont working and not giving any error

var bmp:Bitmap=new Bitmap(BitmapData.fromFile("img/ball.png"));
var h:Object = {};
h.__set("bitmap", bmp);
var bmp2 = h.__get("bitmap");//this is working
bmp2.x=10;//so this is too

I cant define new bitmap or anything for every player when i should change its value(btw i am not changing its value with this way, i am changing a new bitmap’s value i guess). I am making a game server and i defining an object for every player. You could give advices for better ways.

I’m not sure this is supposed to work.

Why use this “Object” class(?) anyway and not bmp directly?

I cant use bmp directly because there is too many of it, as i said, i am making a game server. I guess i should use Map

The reason is that __get (I assume) returns either openfl.utils.Object, or Dynamic. The compiler does not know that the type is really a DisplayObject

We use getters and setters, which are functions in Haxe. Instead of “x = 10” we need “set_x (10)”

Try this

cast (h.__get ("bitmap"), Bitmap).x = 10;

Then the compiler will know to use the setter function

This is exactly what i need. Thanks :slight_smile: