2012-03-18 25 views
0

我发现了一个应用程序,用于读取有关您的摄像头的信息。 问题是,当应用程序启动时,你需要点击它来查看你的统计数据。flex中的自动运行应用程序

我现在已经将应用程序连接到一个按钮,该按钮用于创建我创建的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> 

回答

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')" 
     /> 

这样,总是选择第一个项目。

+0

以及几乎我需要的帮助:) 反正有,但我可以但从标签内的列表中的信息?所以当我按下按钮显示标签放置放置列表正在生成的信息。因为我想按钮显示来显示信息。谢谢 – Dymond 2012-03-18 21:07:28

+1

@FelipeOtarola你不希望列表最初可见?然后,而不是'creationComplete'在'show'中做。 – Manish 2012-03-18 21:09:58

+0

作品完美:) 谢谢 – Dymond 2012-03-18 21:23:28

相关问题