Map type and invalid field error

var fd_gfx = new Map<String, Dynamic>();
var fd_db_gfx = new Map<String, Dynamic>();
Yes, I know you do not like Dynamic, but I know what I am doing and I used unspecified arrays for years in JS/PHP/AS3 without experiencing bugs.
I prefer to have all sprites, bitmaps, and bitmapdatas in one variable, dynamic array, so lets focus on error itself.
fd_gfx['screen'] = new Sprite ();
fd_gfx['screen'].x = (stage.stageWidth - fd_settings['width']) / 2;
fd_gfx['screen'].y = (stage.stageHeight - fd_settings['height']) / 2;
Gives me error on runtime (windows target) “Invalid field: x”.
fd_gfx['screen-background'] = new Bitmap ();
fd_gfx['screen-background'].smoothing = true;
fd_gfx['screen'].addChild(fd_gfx['screen-background']);
fd_db_gfx['b1'] = Assets.getBitmapData ("data/gfx/b1.png");
fd_gfx['screen-background'].bitmapData = fd_db_gfx['b1'];
Gives me error on runtime (windows target) “Invalid field: bitmapData”.
It seems like there is a problem with “x” and “bitmapData”, but no problem with “smoothing”.
What is going on here?
Storing objects in maps does not give access to their functions?
If yes, then what is alternative solution to achieve similar thing (one associative array of various objects with ability to access their functions)?

I think you can’t rely on getters of properties such as get_x() and get_y() being called when accessed through Dynamic. You’d have to cast to the appropriate type first.

Try Reflect.getProperty() and Reflect.setProperty(). They’re slower and more verbose, but they account for this situation.

Reflect.setProperty(fd_gfx['screen'], 'x', (stage.stageWidth - fd_settings['width']) / 2);
Reflect.setProperty(fd_gfx['screen'], 'y', (stage.stageHeight - fd_settings['height']) / 2);

Alternatively, cast your objects before accessing properties:

(fd_gfx['screen']:Sprite).x = (stage.stageWidth - fd_settings['width']) / 2;
(fd_gfx['screen']:Sprite).y = (stage.stageHeight - fd_settings['height']) / 2;
//...
(fd_gfx['screen-background']:Bitmap).bitmapData = fd_db_gfx['b1'];

Well, good to know about such alternatives.
I think I will finally end up with three separated arrays like fd_gfx = new Map<String, Sprite>(); fd_gfx_img = new Map<String, Bitmap>(); fd_gfx_data = new Map<String, BitmapData>();
I wonder why some functions are working, like smoothing or addChild, and others not, in case of using Dynamic.
So, if I decide to use fd_settings = new Map<String, String>(); instead of Dynamic for data loaded from external config file, then which way for int values stored as string would be best practice, fd_gfx[‘screen’].x = (fd_settings[‘position-x’]:Int); or fd_gfx[‘screen’].x = Int(fd_settings[‘position-x’]); (my favorite method from AS3, since it is similar to other languages I use, but I did not test it in OpenFL yet) or fd_gfx[‘screen’].x = (fd_settings[‘position-x’] as Int); or no matter or something other?

I wonder why some functions are working, like smoothing or addChild, and others not, in case of using Dynamic.

Like I said, it’s about properties with getters. smoothing and addChild() aren’t properties.