【发布时间】:2010-04-05 23:27:52
【问题描述】:
我在将数据从函数显示到选项卡中的文本框时遇到问题。 如果您运行代码并单击“选择选项卡 2 并填充...”,则会出现错误; “TypeError:错误 #1009:无法访问空对象引用的属性或方法。” 我猜这是因为“Tab 2”尚未呈现/尚未呈现。现在,如果我运行代码, 选择“Tab 2”,然后选择“Tab 1”,然后单击“Select Tab 2 and Fill ...”它可以工作 我想要的方式。任何人都知道解决此问题的方法。
----Full Flex 4/Flash Builder 代码只需复制粘贴----
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
creationComplete=" ">
<fx:Script>
<![CDATA[
public function showtab2():void
{
mytextbox.text="I made it!";
tn.selectedIndex=1;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:Panel title="TabNavigator Container Example" height="90%" width="90%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:Label width="100%" color="blue"
text="Select the tabs to change the panel."/>
<mx:TabNavigator id="tn" width="100%" height="100%">
<!-- Define each panel using a VBox container. -->
<mx:VBox label="Panel 1">
<mx:Label text="TabNavigator container panel 1"/>
<mx:Button label="Select Tab 2 and Fill with Text" click="showtab2()"/>
</mx:VBox>
<mx:VBox label="Panel 2">
<mx:Label text="TabNavigator container panel 2"/>
<s:TextInput id="mytextbox" />
</mx:VBox>
</mx:TabNavigator>
<mx:HBox>
</mx:HBox>
</mx:Panel>
</s:WindowedApplication>
【问题讨论】:
标签: apache-flex actionscript-3 air