A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Error while finding object's index in an array

Threaded View

  1. #1
    Member
    Join Date
    Nov 2007
    Posts
    83

    Error while finding object's index in an array

    I've an array with some properties. When I try to find an object's index I'm getting error TypeError: Error #1009. I'm using Flash CS6.

    Here's my array:

    Code:
    var squareArr:Object  = {
         a1: {
              piece: wr1_txt,
              pieceLoc: {  
                x: "-3",
                y: "347"
              }
         },
         b1: {
              piece: wn1_txt,
              pieceLoc: {  
                x: "47",
                y: "347"
              }
         },
    ...
    Below code is giving me error #1009 while I want it to return a1:

    Code:
    trace (squareArr.indexOf(wr1_txt));
    I tried:

    Code:
    var s:String;
    var found:Boolean=false;
    for (s in squareArr) {
        if (squareArr[s].piece == wr1_txt) { // YAY found it
            found=true;
            break;
        }
    }
    if (found) trace(s); else trace("Not found!");
    but it says not found
    Last edited by onurcan1977; 05-28-2014 at 09:21 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center