Detailed usage Flex When you encounter such a problem, New Come out Component Internal components cannot be operated directly. Null . Of course, we are writing Script You can set Children In Constructor . In this way, this problem will not occur. But when we are doing Mxml This problem is very obvious when components are used. We must follow Flex Of Component Life Cycle . The common practice is to put Property Inside , For example
<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: canvas xmlns: MX = "http://www.adobe.com/2006/mxml" width = "400" Height = "300">
<Mx: SCRIPT>
<! [CDATA [
Private var title: string;
Private var bnamechanged: Boolean;
Public Function set title (value): void
{
If (title! = Value)
{
Title = value;
Bnamechanged = true;
This. invalidateproperties ();
}
}
Override protected function commitproperties (): void
{
Super. commitproperties ();
If (bnamechanged)
{
Bnamechanged = false;
Lblname. Text = title;
}
}
]>
</MX: SCRIPT>
<Mx: Label id = "lblname"/>
</MX: canvas>
However, you are usingContainerInNullBut what is the problem? For example, you put two components on oneTabnavigate.
<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute" xmlns: Local = "*">
<Mx: tabnavigator>
<Local: testcomponent id = "test1" Title = "Test 1"/>
<Local: testcomponent id = "Test2" Title = "Test 2"/>
</MX: tabnavigator>
</MX: Application>
Try to ensure
Error #1009: the attribute or method referenced by the null object cannot be accessed.
At this time, I started to complain. Why?FlexWhy do you not comply with your game rules?,HereTabnavigatorOfChildrenIt is called before it is created,CommitepropertiesOrUpdatedisplaylistMethod. This should beFlexOneBug.
To solve this problem, we only needTabnavigatorIn the createChildrenAllChildrenAre created. At this time, we need to pay attentionContainer. createpolicyAttribute.ContainerInternalChildrenNot inCreatechildAs forChildrenThe creation time, take a good look
Containercreationpolicy,AndContainerInternalChildren (PassMxmlAddedChildren)AndCreatechildrenCreated inChidrenIt can be understood as different types.
In the above exampleTabnavigatorAddCreatepolicy = "all"All files are fixed.
If you have any questions, please correct them..