Reputation: 2277
I found an application that read the information about you webcam. The thing is that when the application start you need to click on it to view your stats.
I have now connected the application to a button that animate the mx:list i created, But anyhow I need to fist click on the list to generate the output on a mx:label.
Any Ideas how I should do to just click on my show button to autorun camera stats.
Thanks
<?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>
Upvotes: 0
Views: 174
Reputation: 3522
First, I split your function in two:
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);
}
Next (and I'm assuming you want the list to be visible to start with):
<mx:List id="list"
dataProvider="{Camera.names}"
width="200"
change="list_change(event);"
hideEffect="{ZoomRotateHide}"
showEffect="{ZoomRotateShow}"
selectedIndex="0"
creationComplete="populateCameraInfo('0')"
/>
So that way the first item is always selected.
Upvotes: 1