For ... in loop giving me an "implicit coercion" error--but describeType says I've got right type?

Hi All,
I've got the following code:
var currentStateIndex:int = 0;
for (var index:int in this.states){
     if(this.currentState == this.states[index].name){
          currentStateIndex = index;
          break;
I'm trying to identify the index of the current state.  It's giving me an error on the for line, saying "Implicit coercion of a value of type String to an unrelated type int."  Hmm, strange, I thought--wouldn't the keys of the this.states array (and it is just a plain vanilla array) be integers?
So, I tried this:
var currentStateIndex:int = 0;
for (var index:* in this.states){
     var theType:* = flash.utils.describeType(index);
     if(this.currentState == this.states[index].name){
          currentStateIndex = index;
          break;
I used the debugger to inspect the value of theType.  It's this:
<type name="int" base="Object" isDynamic="false" isFinal="true" isStatic="false">
  <extendsClass type="Object"/>
  <constructor>
    <parameter index="1" type="*" optional="true"/>
  </constructor>
</type>
So, indeed, describeType says that the index value is of type "int"... so why can't I strongly type it as an int?

rtalton wrote:
This works:
                var currentStateIndex:int;
                 for (var idx:String in this.states) {
                    if (this.currentState == this.states[idx].name) {
                        //the names match!
                        currentStateIndex = int(idx);//cast as an integer.
                        break;
But using your method you will never get a match for the base state, which is always "null", and does not have a name property.
What is the right way to identify the index of the current state, if the current state is the default state?

Similar Messages

  • Does anyone know how to delete the back up for the ipod? I am getting an error message that says "iTunes could not back up iPod because it is corrupt or not compatible with iPod; delete back up and try again"

    does anyone know how to delete the back up for the ipod? I am getting an error message that says "iTunes could not back up iPod because it is corrupt or not compatible with iPod; delete back up and try again"

    Go to iTunes>Preferences>Devices and highlight the backup you want to delete and click on Delete Backup

  • Had my Nikon D600 recently in for the updated service call. Camera works fine but Photoshop says it cannot open my RAW (NEF) files now? It worked fine before and I have done all my updates.

    Had my Nikon D600 recently in for the updated service call. Camera works fine but Photoshop says it cannot open my RAW (NEF) files now? It worked fine before and I have done all my updates.

    The only thing I can think of is if you got a replacement D610 as rumored here:
    http://nikonrumors.com/2014/01/27/nikon-is-replacing-some-d600-cameras-with-new-d610-model s.aspx/
    In that case, you would need the new version of Camera RAW or DNG converter as per Camera Raw plug-in | Supported cameras .
    The other thing to check is if the files open in the Nikon native ViewNX software. If they don't it's time to call the service center.

  • I am trying to load LR on my new macbook pro. It asks for the serial number. I enter the digits, but it says, quote, " This is an upgrade serial number. The serial number from your previous version of Lightroom is also required."

    I am trying to load LR on my new macbook pro. It asks for the serial number. I enter the digits, but it says, quote, " This is an upgrade serial number. The serial number from your previous version of Lightroom is also required."

    If you still have the old computer and it is a MAC, the Lightroom 5 serial numbers are in a text file.
    users/"username"/Library/Application Support/Adobe/Lightroom/Lightroom 5.0 Registration
    More info here
    Preference and other file locations in Lightroom 5

  • Trying to reset my password (which I have forgot) for elements 13 I have the serial no.  But I can't find the right website to reset? I have "copy & paste " into the browser.

    trying to reset my password (which I have forgot) for elements 13 I have the serial no.  But I can't find the right website to reset? I have "copy & paste " into the browser.

    Go to the main page of adobe.com and sign out if you're already signed in there. Then click Sign In at the upper right of the page. In the next page you will see a Forgot Password link:

  • I have just purchased elements 12. It will not convert a raw file for me. i have downloaded DNG convertor 8.5 but it says that my Canon 70d is not compatible. I never had a problem with my last camera canon 7d and elments 8. Can someone help me please..

    i have just purchased elements 12. It will not convert a raw file for me. i have downloaded DNG convertor 8.5 but it says that my Canon 70d is not compatible. I never had a problem with my last camera canon 7d and elments 8. Can someone help me please

    Did you buy PSE in the mac app store? If not, just go to Help>Updates in the editor and update camera raw and you should be able to open the raw files in PSE 12 directly without the DNG converter.

  • I have cs4 master and I want to get creative cloud which it says you can get for lower price if you have cs3 or higher but it says i can't why?

    I have cs4 master and I want to get creative cloud which it says you can get for lower price if you have cs3 or higher but it says i can't why?

    Hi Quinn7,
    Was the one which you were upgrading from a Educational version? If so, that might be related. I'd recommend reaching out to our support for assistance. I think there is a link for chat or phone on the bottom of the plans page: Creative Cloud pricing and membership plans | Adobe Creative Cloud
    - Dave

  • Implicit coercion Error while Adding Dynamic Rows To Flex DataGrid

    Hi friends
    I   want to add interger for in next next rows while clicking tab   button,one i enter all the values in one row if i press tab means next   row will be editable.for making that i added the following code.i have   some error shows like this
        [Bindable]
                    private var tasks:ArrayCollection;
                    private static const ADD_TASK:int= "";
                    private function init():void
                        tasks = new ArrayCollection();
                        tasks.addItem(new Task(0.01,100000,0));
                        tasks.addItem({frmAmount:ADD_TASK});
                    private function checkEdit(e:DataGridEvent):void
                        // Do not allow editing of Add Task row except for
                        // "Click to Add" column
                        if(e.rowIndex == tasks.length - 1 && e.columnIndex != 0)
                            e.preventDefault();
            private function editEnd(e:DataGridEvent):void
                    // Adding a new task
                    if(e.rowIndex == tasks.length - 1)
                    var txtIn:TextInput =TextInput(e.currentTarget.itemEditorInstance);
                    var dt:Object = e.itemRenderer.data;
                    // Add new task
                    if(parseInt(txtIn.text) != ADD_TASK)
                        tasks.addItemAt(new Task(parseInt(txtIn.text), 0, ""), e.rowIndex);----->Multiple markers at this line:
                                                                                                                               -1067: Implicit  coercion of a value of type String to an unrelated type int.
                                                                                                                                  -txtIn
                    // Destroy item editor
                    commPlanDetGrid.destroyItemEditor();
                        // Stop default behavior
                    e.preventDefault();
            ]]>
    Please help if any suggession
    Thanks in advance
    B.Venkatesan

    Venktesan,
    You are trying compare String and int..! which is not possible try to case the txtIn.text to int using parseInt(txtIn.text).
    ORIGINAL:
    if(txtIn.text != ADD_TASK).---->error : Comparison between a value with static type String and a possibly unrelated type int
                        tasks.addItemAt(new Task(txtIn.text, 0, ""), e.rowIndex);----> error:Implicit coercion of a value of type String to an unrelated type int.
    EDITED:
    if(parseInt(txtIn.text) != ADD_TASK).---->error : Comparison between a value with static type String and a possibly unrelated type int
                        tasks.addItemAt(new Task(parseInt(txtIn.text), 0, ""), e.rowIndex);----> error:Implicit coercion of a value of type String to an unrelated type int.
    Thanks
    Pradeep

  • HT2822 My Apple TV keeps saying to turn on home sharing in iTunes. It is already on.  I think maybe the network is wrong.  I put in the right password for it but it says it's not right.  Please help. I am so frustrated with this.

    Sorry i wrote everything in the topic.

    If you are running iTunes 11 on a 64bit Win7 PC, try running iTunes in XP Compatibility mode. It doesn't make much sense, but it worked for me.

  • I can't get my itunes to update it keeps giving me a run time error but every time it tells me to uninstall and reinstall I keep getting the same error.

    I keep trying to update itunes but it gives me a run time error and tells me to uninstall and then reinstall. It is driving me crazy. Any suggestions?

    Hi, I had this problem too and Barton (bless you) has said
    1. go to C:\ programe files(x86) itunes & c:programesfiles/itunes. look for all .dll iles
    2. QT movie.DLL ( I didn't have this file) and all .dll files. and move to the desk top.
    I did any file that had a .dll after it.
    3. reboot your computer.
    4. Uninstall Itunes and anything that is related with Apple. eg Quicktime,Bonjour. what ever says Apple is the publisher.
    5. Reboot computer
    6. go to Itunes and down load again.
    This fixed my computer and it took me 3 days until a remote assistant guys that I used for another problem told me to go on community Itunes.
    I tried a few of the suggestions but had trouble following but this is pretty simple even for me.
    Good luck

  • Tried the solutions posted for this "SubVI filter not executable​. Undefined error" but not solving the problem

    Hello,
    I am trying to use a lowpass filter for my application but getting the error "SubVI filter not executable. Undefined error".I tried working with the solutions at this post 
    http://forums.ni.com/t5/LabVIEW/SubVI-filter-not-e​xecutable-Undefined-error/m-p/1996701#M657751 and results with
    1. Create a blank vi, put a VI filter in the block diagram (this should not be functional as it is not wired), copy it and paste it in my other project. I believe if the filter is the first vi of a blank project, it is funcitonal and then you may copy it wherever you need to.
    Result:
    2.Tried to open the filter panel of the Filter but showing the same error as shown inthe below image
    Don't why the solutions worked for others are not working.Can someone suggest a solution for this.
    thanks in advance.

    Hi PatanGova,
    Very strange error. Actually, there are no required inputs on this express VI, so it should be able to run even without wires. It is not correct as you said: "this should not be functional as it is not wired". Nothing will happen, true, but the run arrow should not be broken.
    For some reason, the VI with the Filter express VI fails to compile. I tried it on my computer (LV 2013) and get no error when I add it to a new VI. As was suggested in the linked forum thread, you need to open the front panel of the Filter VI and run it to see the explicit error.
    If you do, do you also get the error:
    "This VI claims to be part of a library that does not include the VI. The VI might have been deleted from the library. Add the VI to the library again or select File - Disconnect from the library."?
    If you do, it seems that you may have a project library somewhere that has taken ownership of the express VI. The ownership prevents you from running or editing the express VI. To free the VI, you need to do one of two things. Either, you need to load the library into memory, or you need to disconnect the VI from the library. Either way, you need to find the project library that has taken the ownership of the VI. As soon as it is released, it should run for you. You release it by selecting File»Disconnect from Library on the VI.
    The workaround described in your link (and also here: http://forums.ni.com/t5/LabVIEW/compatibility-prob​lem-labview-2009-2010-2011-quot-This-VI-claims/td-​... tells that you can make a copy of the VI and thereby create another instance that is free. This solution may work for you as well, but if not, you may not have created the copy properly. Maybe your copy of the VI also became part of some project library that took ownership. In either way, you should rather find the project library to release the VI before trying the workaround to copy it.
    If project library ownership is not the problem, maybe the problem is connected to LV 2011, as most forum posters report that it only happens here.

  • Iphone Is Disabled For Trying To Unlock My Phone To Many Times , But It Says Connect To Itunes. Help?

    So I Just Got My Iphone Back From The Store Fixing It , And I Just Got It Back In 4 Months , And As Soon As I Got It I Had a passcode i put on it and i tried to many attempts and it was disabled for 60 minutes , after the time was up i tried again and now its disabled and says connect to itunes , can someone please give me some brief instructions please i really want to get my phone unlocked!

    put it in recovery mode as explained here:
    iOS: Unable to update or restore

  • Everytime i try to download iso5 update for my iphone 4  i keep getting an error and it says if i proceed to update i will lose all contents in my phone?

    im having trouble downloading the new update iso5 .  . . . everytime it is almost to the end of downloading an error will pop up...? help please

    What exactly does the error say?
    Updating to iphone 5 does indeed erase your iphone, then it restores the data (assuming you have made sure that everything on your iphone is on your computer first).

  • FOR/NEXT loop produces Error in ProcessSQL: Subscript out of range

    Hi all,
    The 2nd FOR/NEXT loop in the following code produces Subscript ouf of Range error:
    *LOOKUP RATEAPP
    *DIM MODEL:RATEENTITYDIM= DRIVEDIM.DRIVER_ENTITY
    *DIM MODEL:RATEACCOUNTDIM= DRIVEDIM.DRIVER
    *DIM MODEL:INPUTCURRENCYDIM = "EUR"
    *ENDLOOKUP
    // Select lookup and normal members by group
    *SELECT(%DRIVERSA%, ID, DRIVEDIM, "[GROUP] = 'A' AND [DRIVER] <> ''")
    *SELECT(%MANUALSA%,ID,DRIVEDIM, "[GROUP] = 'A' AND [SOURCE] = 'MAN'")
    *XDIM_MEMBERSET DRIVEDIM= %MANUALSA%, "U_TEMP"
    *WHEN ACCOUNTDIM.ACCTYPE
    *IS *
         *REC(EXPRESSION=1, NOADD, DRIVEDIM="U_TEMP")
    *ENDWHEN
    *GO
    // this is ok
    *FOR %MANSET% = %MANUALSA%
         *WHEN DRIVEDIM
         *IS %MANSET%
         *WHEN %VALUE%
         *IS <> 0
                   *REC(FACTOR=GET(DRIVEDIM="AD.TEMP"),DRIVEDIM="AD.TEMP")
         *ENDWHEN
         *ENDWHEN
    *GO
    *NEXT
    *XDIM_MEMBERSET DRIVEDIM= %DRIVERSA%, "U_TEMP"
    // this is not OK
    *FOR %DRIVSET% = %DRIVERSA%
         *WHEN DRIVEDIM
         *IS %DRIVSET%
              *WHEN %VALUE%
              *IS <> 0
                   *REC(FACTOR= GET(DRIVEDIM="U_TEMP") * LOOKUP(MODEL),DRIVEDIM="U_TEMP") //  * LOOKUP(MODEL)
              *ENDWHEN
         *ENDWHEN
    *GO
    *NEXT
    If I remove the FOR/NEXT loop, this runs fine. The error occurs everywhere - in logic debugger, in DB, in ExecuteBaseLogic if included in Default logic. The REC statement inside the loop can be anything, even as simple REC(FACTOR=1,DRIVEDIM="U_TEMP"), so the problem is in the loop, not anything else. It validates nicely and the compiled logic looks just as expected.
    This error could occur sometimes if the membersets are too large. However, in this example, the number of members is rather limited. In the debugger is is possible to limit the data region to single specific intersection and the DRIVEDIM membersets combined is exacly 15.
    Could it be possible that the error is caused by member ID-s like AD.1.AVGWAGEGROWTH (length=18)? Is there anything else that can cause  trouble?
    Any ideas appreciated.
    Thanks
    Madis
    Edited by: Madis Udam on Mar 24, 2011 11:06 AM

    I don't think you should have"." dot's in you ID's.
    think about it, in your code you have ACCOUNTDIM.ACCTYPE, which represents the account type of the dimension.
    If you have an id "AD.1.AVGWAGEGROWTH"; wouldn't it think that you are trying the get a value of some member?
    That's just a guess, we established that we wouldn't use any special characters on our id's
    It's working so far
    Try changing the line
    *IS %DRIVSET%
    to
    *IS "%DRIVSET%"
    Edited by: Leandro Cardoso Feliciano on Mar 28, 2011 10:45 PM

  • Implicit coercion of a value of type String to an unError while Adding Dynamic Rows To Flex DataGrid

    Hi friends
    I  want to add interger for in next next rows while clicking tab  button,one i enter all the values in one row if i press tab means next  row will be editable.for making that i added the following code.i have  some error shows like this
        [Bindable]
                    private var tasks:ArrayCollection;
                    private static const ADD_TASK:int= "";
                    private function init():void
                        tasks = new ArrayCollection();
                        tasks.addItem(new Task(0.01,100000,0));
                        tasks.addItem({frmAmount:ADD_TASK});
                    private function checkEdit(e:DataGridEvent):void
                        // Do not allow editing of Add Task row except for
                        // "Click to Add" column
                        if(e.rowIndex == tasks.length - 1 && e.columnIndex != 0)
                            e.preventDefault();
            private function editEnd(e:DataGridEvent):void
                    // Adding a new task
                    if(e.rowIndex == tasks.length - 1)
                    var txtIn:TextInput =TextInput(e.currentTarget.itemEditorInstance);
                    var dt:Object = e.itemRenderer.data;
                    // Add new task
                    if(parseInt(txtIn.text) != ADD_TASK)
                        tasks.addItemAt(new Task(parseInt(txtIn.text), 0, ""), e.rowIndex);----->Multiple markers at this line:
                                                                                                                             -1067: Implicit coercion of a value of type String to an unrelated type int.
                                                                                                                                -txtIn
                    // Destroy item editor
                    commPlanDetGrid.destroyItemEditor();
                        // Stop default behavior
                    e.preventDefault();
            ]]>
    Please help if any suggession
    Thanks in advance
    B.Venkatesan

    The error message indicates the problem fairly clearly.  _feed_list is defined as a ComboBox in your first line of code.  You are passing that as an argument in your populate(_feed_list) line of code.  However, the populate function is expecting an XMLList object to be passed, not a ComboBox.
    You probably really mean to be using...
              populate(feed_items);
    since that is the only XMLList to be found

Maybe you are looking for

  • PC synch 7 has a mind of it's own!!!!

    despite being a nokia user since 1999 pc synch & has me almost convinced to change to a different manufacturer. despite setting it to synch only diary info (because synching contacts on this phone has always been a disaster!, only to synch from compu

  • How do i transfer the music and apps from ipod touch to iphone

    how do i transfer the music and apps from ipod touch to iphone

  • How to get contacts unlinked from old email and put onto iCloud

    I have an OLD hotmail account I haven't used in 10+ years that I was using as my Windows Live login when I had a Windows phone a few years ago. I linked it when I got my iPhone, and I think it became associated with a lot of my contacts. Now, I don't

  • USB port is not working,

    I have HP Pavillion p6230in purchased on 30/4/2010 in New Delhi, India.  In my PC USB Port and DVD drive is not working.  I have loged complaint with Service Centre 4/3/2011 but in vain no one has visited my place for repair.  I do my self system rec

  • How to save then quit excel using activeX

    The task that I need to do is open existing excel file, append data to the last row, save data then close it. Everything works fine except saving the data. I used property workbook note to save then invoke node to close a workbook then invoke node to