Flash / AIR AS3: comparing the contents of Screen.screens

In a normal world, this works as expected:

var array:Array = ['a','b','c'];
trace(array.indexOf(array[0])); // returns 0

In a crazy world, this happens:

trace(Screen.screens.indexOf(Screen.screens[0])); // returns -1

... if Screen.screensis Arrayavailable instances Screenwhy this array can not give an accurate indexOfone of their own children?

edit - To take another step, check this:

for each(var i:Screen in Screen.screens){
 for each(var j:Screen in Screen.getScreensForRectangle(this.stage.nativeWindow.bounds)){
  trace(i, j, i == j); // returns false
  trace(i.bounds, j.bounds, i.bounds == j.bounds); // returns false
 }
}

At least one Screenspecified in Screen.screensshould be identical Screento Screen.getScreensForRectangle(this.stage.nativeWindow.bounds)- but even if you compare Screen.bounds, it still does not match, despite two Rectangleobjects with the same size!

Madness, ladies and gentlemen! You don’t even want to see the workaround I collected (hint: it involves comparing the values Screen.bounds.toString()for the content Screen.screens)

+3
1

(?) , Screen.screens , , , , , , , , , Flash Screen ( Screen ). :

Screen.screens.indexOf(Screen.screens[0])

Screen.screens, , , , , indexOf == = , Screen , .

, . :

var scr:Array = Screen.screens;
trace( scr.indexOf(scr[0]) ); // returns 0
+2

Source: https://habr.com/ru/post/1739067/


All Articles