我找到了一个应用程序来读取有关您网络摄像头的信息。 问题是,当应用程序启动时,您需要单击它以查看您的统计信息。
我现在已将应用程序连接到一个按钮,该按钮为我创建的mx:list设置动画,但无论如何我需要先点击列表以在mx:label上生成输出。
任何想法我应该怎么做才能点击我的节目按钮来自动运行相机统计数据。
由于
<?xml version="1.0"?>
<!-- behaviors\CompositeEffects.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
import mx.utils.ObjectUtil;
private var camera:Camera;
private function list_change(evt:ListEvent):void {
var tList:List = evt.currentTarget as List;
var cameraName:String = tList.selectedIndex.toString();
camera = Camera.getCamera(cameraName);
textArea.text = ObjectUtil.toString(camera);
}
]]>
</mx:Script>
<mx:Parallel id="ZoomRotateShow">
<mx:Zoom id="myZoomShow"
zoomHeightFrom="0.0"
zoomWidthFrom="0.0"
zoomHeightTo="1.0"
zoomWidthTo="1.0"
/>
<mx:Rotate id="myRotateShow"/>
</mx:Parallel>
<mx:Sequence id="ZoomRotateHide">
<mx:Rotate id="myRotateHide"/>
<mx:Zoom id="myZoomHide"
zoomHeightFrom="1.0"
zoomWidthFrom="1.0"
zoomHeightTo="0.0"
zoomWidthTo="0.0"
/>
</mx:Sequence>
<mx:List id="list"
dataProvider="{Camera.names}"
width="200"
change="list_change(event);"
hideEffect="{ZoomRotateHide}"
showEffect="{ZoomRotateShow}" visible="false"
/>
<mx:Label id="textArea" height="185" x="674" y="228" dataChange="{Camera.names}" />
<mx:Button id="myButton1"
label="Show!"
click="list.visible=true;"
/>
<mx:Button id="myButton2"
label="Hide!"
click="list.visible=false;"
/>
</mx:Application>
答案 0 :(得分:1)
首先,我将你的功能分成两部分:
private function list_change(evt:ListEvent):void {
var tList:List = evt.currentTarget as List;
populateCameraInfo(tList.selectedIndex.toString());
}
private function populateCameraInfo(cameraName:String):void {
camera = Camera.getCamera(cameraName);
textArea.text = ObjectUtil.toString(camera);
}
接下来(我假设您希望列表以可见的方式开头):
<mx:List id="list"
dataProvider="{Camera.names}"
width="200"
change="list_change(event);"
hideEffect="{ZoomRotateHide}"
showEffect="{ZoomRotateShow}"
selectedIndex="0"
creationComplete="populateCameraInfo('0')"
/>
这样,第一项始终被选中。