2011-05-15 1 views
-1

이벤트 리스너는 사람이 코드이 코드에서 이벤트 리스너가 실행되지 않으면 아무도 가이드 할 수 있습니까?

<?xml version="1.0" encoding="UTF-8"?> 
<mx:HBox creationComplete="{initComponent();}" height="51" rollOut="{isOnControl = false;setTimer(true);}" rollOver="{isOnControl = true;setTimer(false);}" backgroundImage="C:\Users\sidd\Desktop\5\bandoochat\Image\image 83.png" verticalAlign="middle" xmlns:mx="http://www.adobe.com/2006/mxml" width="240"> 
    <mx:Script><![CDATA[ 
     import assets.EmbeddedAssets_menuRadioIcon; 

     import com.myproj.classes.*; 
     import com.myproj.events.*; 
     import com.myproj.interfaces.*; 

     import flash.events.*; 
     import flash.utils.*; 

     import mx.binding.*; 
     import mx.collections.*; 
     import mx.containers.*; 
     import mx.controls.*; 
     import mx.core.*; 
     import mx.effects.*; 
     import mx.events.*; 
     import mx.styles.*; 


     [Binding] 
     private var toolbarTimer:Timer; 
     private var toolbarAnimationPlaying:Boolean = false; 
     private var audioDevices:ArrayCollection; 
     private var cameraCollection:Array; 
     private var isOnMenu:Boolean = false; 
     private var cameraDevices:ArrayCollection; 
     private var audioCollection:Array; 
     private var _controller:IControlManager; 
     private var toolbarMoveEffect:Fade; 
     private var cameraChoose:PopUpButton; 
     private var cameraDevicesMenu:Menu; 
     private var audioDevicesMenu:Menu; 
     private var isOnControl:Boolean = false; 

     public function resetToolbarTimer(event:MouseEvent = null) : void 
     { 
      setTimer(false); 
      setTimer(true); 
      if (!toolbarAnimationPlaying) 
      { 
       toolbarAnimationPlaying = true; 
       setToolbarState(true); 
      } 
      return; 
     }// end function 


     public function setTimer(param1:Boolean) : void 
     { 
      if (this.includeInLayout) 
      { 
       if (!param1) 
       { 
        toolbarTimer.stop(); 
        toolbarTimer.reset(); 
       } 
       else 
       { 
        toolbarTimer.reset(); 
        toolbarTimer.start(); 
       } 
      } 
      return; 
     }// end function 


     public function videoSelectedHandler(event:MenuEvent) : void 
     { 
      var i:int = 0; 
      while (i < cameraDevices.length) 
      { 

       cameraDevices.getItemAt(i).icon = null; 
       i++; 
      } 
      event.item.icon = EmbeddedAssets_menuRadioIcon; 
      _controller.setNewCamDevice(event.index); 
      return; 
     }// end function 


     public function muteAudio() : void 
     { 
      _controller.muteAudio(); 
      return; 
     }// end function 


     public function initComponent() : void 
     { 
      toolbarTimer.addEventListener(TimerEvent.TIMER, toolbarTimerHandler); 
      this.parent.addEventListener(MouseEvent.MOUSE_MOVE, resetToolbarTimer); 
      this.parent.addEventListener(MouseEvent.ROLL_OUT, function() : void 
      { 
       setTimeout(toolbarTimerHandler, 200); 
       return; 
      }// end function 
      ); 
      _controller.addEventListener(ControlManagerEvent.onNoCamerasFound, onNoCamerasFound); 
      audioCollection = _controller.microphones; 
      var i:int; 
      while (i < audioCollection.length) 
      { 

       audioDevices.addItem({label:audioCollection[i], icon:i == 0 ? (EmbeddedAssets_menuRadioIcon) : (null)}); 
       i = (i + 1); 
      } 
      audioDevicesMenu = Menu.createMenu(this, audioDevices); 
      audioDevicesMenu.addEventListener(MouseEvent.MOUSE_OVER, function() : void 
      { 
       isOnMenu = true; 
       return; 
      }// end function 
      ); 
      audioDevicesMenu.addEventListener(MouseEvent.MOUSE_OUT, function() : void 
      { 
       isOnMenu = false; 
       return; 
      }// end function 
      ); 
      audioDevicesMenu.addEventListener(MenuEvent.ITEM_CLICK, audioSelectedHandler); 
      audioDevicesMenu.width = 200; 
      cameraCollection = _controller.cameras; 
      var j:int; 
      while (j < cameraCollection.length) 
      { 

       cameraDevices.addItem({label:cameraCollection[j], icon:j == 0 ? (EmbeddedAssets_menuRadioIcon) : (null)}); 
       j = (j + 1); 
      } 
      cameraDevicesMenu = Menu.createMenu(this, cameraDevices); 
      cameraDevicesMenu.addEventListener(MouseEvent.MOUSE_OVER, function() : void 
      { 
       isOnMenu = true; 
       return; 
      }// end function 
      ); 
      cameraDevicesMenu.addEventListener(MouseEvent.MOUSE_OUT, function() : void 
      { 
       isOnMenu = false; 
       return; 
      }// end function 
      ); 
      cameraDevicesMenu.addEventListener(MenuEvent.ITEM_CLICK, videoSelectedHandler); 
      cameraDevicesMenu.width = 200; 
      return; 
     }// end function 


     public function onNoCamerasFound(event:ControlManagerEvent) : void 
     { 
      this.includeInLayout = false; 
      this.visible = false; 
      return; 
     }// end function 


     public function setToolbarState(param1:Boolean) : void 
     { 
      if (this.includeInLayout) 
      { 
       if (!isOnControl) 
       { 
        if (toolbarMoveEffect.isPlaying) 
        { 
         toolbarMoveEffect.reverse(); 
         return; 
        } 
        toolbarMoveEffect.alphaFrom = !param1 ? (1) : (0); 
        toolbarMoveEffect.alphaTo = param1 ? (1) : (0); 
        toolbarMoveEffect.play(); 
       } 
      } 
      return; 
     }// end function 


     public function toolbarTimerHandler(event:Event = null) : void 
     { 
      if (!isOnMenu) 
      { 
       audioDevicesMenu.hide(); 
       cameraDevicesMenu.hide(); 
       toolbarAnimationPlaying = false; 
       setTimer(false); 
       setToolbarState(false); 
      } 
      return; 
     }// end function 


     public function muteVideo() : void 
     { 
      _controller.muteVideo(); 
      return; 
     }// end function 



     public function _LocalCameraControls_Fade1_i() : Fade 
     { 
      var fade:* = new Fade(); 
      toolbarMoveEffect = fade; 
      fade.duration = 220; 
      BindingManager.executeBindings(this, "toolbarMoveEffect", toolbarMoveEffect); 
      return fade; 
     }// end function 


     public function audioSelectedHandler(event:MenuEvent) : void 
     { 
      var i:int = 0; 
      while (i < audioDevices.length) 
      { 

       audioDevices.getItemAt(i).icon = null; 
       i++; 
      } 
      event.item.icon = EmbeddedAssets_menuRadioIcon; 
      _controller.setNewMicDevice(event.index); 
      return; 
     }// end function 

    ]]></mx:Script> 

    <mx:HBox horizontalGap="1" paddingTop="12" verticalAlign="middle" width="100%"> 
     <mx:Canvas> 
      <mx:PopUpButton id="audioChoose" popUpStyleName="popupStyle" visible="true"/> 
      <mx:Image click="{muteAudio();}" id="camMicIcon" toolTip="Mute Mic" source="C:\Users\sidd\Desktop\5\bandoochat\Image\image 63.png"/> 
     </mx:Canvas> 
     <mx:Image click="{audioChoose.open();}" id="camAudioSelector1" toolTip="Select audio device" source="C:\Users\sidd\Desktop\5\bandoochat\Image\image 104.png"/> 
     <mx:Spacer width="100%"/> 
     <mx:HBox horizontalGap="1"> 
      <mx:Canvas> 
       <mx:PopUpButton id="cameraChoose1" popUpStyleName="popupStyle" /> 
       <mx:Image click="{muteVideo();}" id="camVideoIcon" toolTip="Turn Camera OFF" source="C:\Users\sidd\Desktop\5\bandoochat\Image\image 56.png"/> 
      </mx:Canvas> 
      <mx:Image click="{cameraChoose.open();}" id="camVideoSelector1" toolTip="Select video device" source="C:\Users\sidd\Desktop\5\bandoochat\Image\image 104.png"/> 
     </mx:HBox> 
    </mx:HBox> 
</mx:HBox> 
+0

어떤 일이 발생했는지, 제대로 작동하지 않고 무엇을 하려는지 구체적으로 알려야합니다. – rzetterberg

+0

@이 코드에서 Ancide 이벤트 리스너가 실행되지 않습니다. –

답변

1

첫 번째로 문제가 무엇인지 저를 인도 할 수이 코드에서 발사하지, 무엇을 "작동하지 않는 수단"을 정량화. 컴파일러 오류가 발생합니까? 또는 런타임 오류? 또는 이벤트 리스너가 실행되지 않습니까? 아니면 다른 일이 있습니까?

둘째, 같은 라인 :

this.parent.addEventListener 

브레이크 캡슐화. 아이는 부모에 대해 아무것도 모를 것입니다. 이것은 보편적으로 나쁜 습관으로 간주됩니다.

귀하의 익명 기능에 대한 사용은 저의 개발 여행에서 이상한 것이지만 그것이 유효하다고 생각합니다. 함수 내에서 중단 점을 설정하여 실행 중인지 확인하십시오.

+0

이벤트 리스너가 문제가 아닌 것을 발사하지 않습니까? –

+0

@Siddhesh Jadhav 그들 중 누구도 발포하지 않으면; initComponent() 메서드는 결코 실행되지 않는다고 생각합니다. 하지만 그게 문제인지 아닌지 말할 수있는 충분한 코드를 제공하지 못했습니다. – JeffryHouser

+0

나는 전체 구성 요소 코드를 붙여 넣었습니다. pls는 지금 thaks를 미리 보았습니다. –

0

모든 이벤트 리스너가 initComponent() 안에 설정되어있는 것을 볼 수 있습니다. 따라서 trace 문을 사용하여 메서드가 호출되는지 확인할 수 있습니다. init 메소드를 호출하기 위해 mxml 파일을 둘러싸고 모든 것이 설정되었는지는 알 수 없습니다.

덧붙여 말하자면, 코드에서 "addEventListener"를 검색 할 때 타이머 및 setTimeout을 사용하는 방법에 문제가 있다는 것을 즉시 알았습니다. 여기를 참조하십시오 : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/package.html#setTimeout%28%29

그게 아무 문제가 없어야하지만 그건 코드에서 바보 같은거야, 그래서 거기에 약간의 오류가 있다고 생각하고 더 완벽하게 모든 코드를 이해해야합니다 하기.

+0

@ jhocking는 내가 어떻게 여기에 추적을 사용해야하는지 말해 줄 수 있습니다. 미리 감사드립니다. –

+0

trace ("here I am"); 특정 개발 환경에서 다른 것을 요구할 수도 있지만 기본 명령입니다. 포인트는 테스트를 위해 콘솔에 메시지를 출력하는 명령입니다. – jhocking

관련 문제