Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 723045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:03:42+00:00 2026-05-14T06:03:42+00:00

In a sane world, this works as expected: var array:Array = [‘a’,’b’,’c’]; trace(array.indexOf(array[0])); //

  • 0

In a sane world, this works as expected:

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

In an insane world, this happens:

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

… if Screen.screens is an Array of the available instances of Screen, why can’t that array give an accurate indexOf one of its own children?

edit – To take it a step further, check this out:

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 Screen listed in Screen.screens should be identical to a Screen in Screen.getScreensForRectangle(this.stage.nativeWindow.bounds) – but even if you compare the Screen.bounds, it still doesn’t match up, despite the two Rectangle objects having the same dimensions!

Insanity, ladies and gentlemen! You don’t even want to see the workaround I put together (hint: it involves comparing the values of Screen.bounds.toString() for the contents of Screen.screens)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:03:43+00:00Added an answer on May 14, 2026 at 6:03 am

    This is an educated(?) guess, but since Screen.screens is read only, and modifying the array it returns has no effect, I think it’s a fairly safe bet that internally, every time you call it Flash generates and returns a new array of Screen objects (rather than keeping an internal set of Screen objects and giving you access to them). When you call:

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

    you make two separate accesses to Screen.screens, so if each of those calls is returning a different array of objects, it’s easy to see why you don’t find any matches – because the indexOf method tests for === equality, so two different Screen objects won’t match, even if they happen to contain information about the same physical screen.

    The solution is to grab a copy of the screens array and use it. This works fine:

    var scr:Array = Screen.screens;
    trace( scr.indexOf(scr[0]) ); // returns 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In any sane programming language, from C to Javascript, an expression such as a
It is often said that in C++11 it is sane to return std::vector by
Is there any sane reason why the function String.Format in .net (for C# and
This question has no practical issues associated with it, it is more a matter
Before someone says this is a dupe, I looked at the other answers regarding
I have a 1D numpy array containing complex numbers (eg. numpy.complex64). I need to
I would like to ask you guys what is the logic behind this: When
I've been trying to track this down for a while but I'm at a
This is a mad-hack , but I am trying to deliberately cause a segfault
I'm tearing my hair out on this one; I want / need / would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.