开发者

Flex error:2025 in migrating to Flex 3 to 4

开发者 https://www.devze.com 2023-03-15 17:00 出处:网络
Currently, I am doing a code migration from Flex 3 to 4 and I am setting currentState in initialize function of a popup.

Currently, I am doing a code migration from Flex 3 to 4 and I am setting currentState in initialize function of a popup.

code is like this,

 currentState = "xyz";

 // Now I try to access child which I am adding in "xyz" state definition.
 var childIndex:int = form.getChildIndex(childId); // this throws error 2025

State definition

<mx:State name="xyz">
    <!-- I remove some children and add some children before this -->   
   <mx:AddChild relativeTo="{form}" position="lastChild"
                creationPolicy="all">
    <mx:FormItem id="childId"
          label="Frequency">
        <mx:ComboBox id="cmbId"
                             dataProvider="{dataP}"
                 selectedIndex="0"
                             change="function()"/>                                     </mx:FormItem>
</mx:AddChild>

This piece 开发者_开发问答of code was working fine until I started compiling code with flex 4.5sdk. Since then, it throws me Error#2025.

Any pointers?


You need to figure out what .parent is for childId prior to calling form.childIndex(childId). A #2025 error should be telling you that childId's parent is not form at the time you are calling form.getChildIndex(childId)

Try adding trace("parent of childId " + childId.parent) before the getChildIndex call:

trace("parent of childId " + childId.parent); 
form.childIndex(childId); 

Or else, update your answer again and include the MXML for form that shows that childId is a direct descendent?


When I tried to getChileIndex for childId in creationComplete method, it worked well. It seems that in initialize phase, we are trying to access a child index of the state and hence we get the error as that child might not have been laid out in the state.

0

精彩评论

暂无评论...
验证码 换一张
取 消