2012-02-10 85 views
0

我試圖簡單地在文本輸入中顯示accelerometerX的更新值,但我不知道如何模擬隨Flash Builder附帶的模擬器上的晃動或微調。以下是我正在使用的代碼。在Adobe AIR for Mobile上模擬搖動手勢/輕推手勢?

<?xml version="1.0" encoding="utf-8"?> 
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     title="MainView" creationComplete="onCreationComplete(event)"> 
    <fx:Script> 
     <![CDATA[ 
      import flash.sensors.Accelerometer; 

      import mx.events.FlexEvent; 

      protected function onCreationComplete(event:FlexEvent):void 
      { 
       var tShake:Accelerometer = new Accelerometer(); 
       tShake.addEventListener(AccelerometerEvent.UPDATE, onAccelerometerUpdate); 
      } 

      protected function onAccelerometerUpdate(event:AccelerometerEvent):void { 
       sampleDisplay.text = event.accelerationX.toString(); 
      } 

     ]]> 
    </fx:Script> 
    <fx:Declarations> 
     <!-- Place non-visual elements (e.g., services, value objects) here --> 
    </fx:Declarations> 
    <s:TextArea id="sampleDisplay" x="14" y="11"/> 
</s:View> 

這是我令人傷心的嘗試使它工作的視頻。當然它不。

http://www.youtube.com/watch?v=3uOOLnXd5qA

回答

0

Adobe Device Central支持模擬輸入加速度,但我認爲這只是支持Flash 10.2的項目。我發現你在Mac上使用Flash Builder,所以如果你使用的是FB4.6/Air 3.1/Flash 11,那麼我認爲它不會起作用。或許更重要的是,我認爲Device Central僅與Flash CS4 +(以及包含Flash的適用CS捆綁軟件)捆綁在一起。 Here is關於有人討論使用它的一個小教程,但如果你沒有它,那不會幫助你。除此之外,我還不知道在Flash Builder 4.6中模擬加速度計事件,除了部署到實際設備並在那裏測試外。

+0

我正在使用Flash Builder 4.5。和Flex SDK 4.5.1。這對你在給定解決方案中的機會有何評論? – Propeller 2012-02-10 16:13:36

+0

如果您有權訪問Device Central(通過安裝Flash CS5.5),則可能有可能。嘗試從bin-debug文件夾中將swf加載到Device Central中,看看會發生什麼。 – 2012-02-10 16:15:56

+0

對不起,聽起來很新鮮,但我怎樣才能真正加載SWF文件?我要去哪? – Propeller 2012-02-10 16:23:33