9
我正在使用ScanHardware函數來獲取更新的相機列表。如果將相機插入我的Mac mini,相機長度正在更新。如果我插入了相機,我的應用程序突然關閉。as3 scanHardware()函數使我的應用程序崩潰
<?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/mx"
height="280"
width="280"
creationComplete="test1()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
public var hardwareTimer:Timer;
public function test1():void{
hardwareTimer = new Timer(5000);
hardwareTimer.addEventListener(TimerEvent.TIMER,refreshHardware);
hardwareTimer.start();
}
public function refreshHardware(ev:TimerEvent):void{
flash.media.scanHardware();
Alert.show(Camera.names.length.toString());
}
]]>
</fx:Script>
</s:WindowedApplication>
如果我使用
Camera.names
我拔掉任何Camera
後,我的應用程序崩潰。
如何解決這個問題?
您的代碼在Windows 10中正常工作。在其他機器上試用它,如果它工作正常,那麼您的機器中可能存在一些問題(AIR版本,凸輪驅動程序,...)... – akmozo
它工作正常在Windows上,我試過了。但它不適用於Mac。 – Vishnu