topical media & game development

talk show tell print

student-editor-net-ximpel-components-MediaClipView.mx

student-editor-net-ximpel-components-MediaClipView.mx [swf] flex


  <?xml version="1.0" encoding="utf-8"?>
  <!-- 
      This program is free software: you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      the Free Software Foundation, either version 3 of the License.
  
      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.
  
      You should have received a copy of the GNU General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
          Javier Quevedo Fernández 05-2009.
  -->
  <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" 
          xmlns:xim="net.ximpel.components.*"
          creationComplete="init();"
          verticalScrollPolicy="off"
          horizontalScrollPolicy="off" alpha="1"
       width="145.18005"
       height="105"
           click="clickHandler(event);"
            mouseOver="mouseOverHandler(event);"
             mouseOut="mouseOutHandler(event)">
  
          <mx:Canvas id="iconBar"  alpha="0.0" horizontalCenter="0" y="66"  height="38" horizontalScrollPolicy="off" verticalScrollPolicy="off" >        
          <mx:HBox id="iconBox" width="80%">
                                  <mx:Image id="addOverlay" toolTip="Add overlays" styleName="VideoViewIconBarIcon" source="net/ximpel/images/addOverlay.png" alpha="{iconInactiveAlpha}" click="addOverlayHandler(event);" mouseOver="closeIconMouseOverHanlder(event)" mouseOut="closeIconMouseOutHandler(event)" />
                                  <mx:Image id="addQuestion" toolTip="Add a question" styleName="VideoViewIconBarIcon" source="net/ximpel/images/addQuestion.png" alpha="{iconInactiveAlpha}" click="addQuestionHandler(event);"  mouseOver="closeIconMouseOverHanlder(event)" mouseOut="closeIconMouseOutHandler(event)" />
                  </mx:HBox>
          </mx:Canvas>
  
          <mx:Canvas horizontalCenter="-1" id="mediaBox" y="7.6" height="59.600006" width="130.90002" styleName="VideoView" horizontalScrollPolicy="off" verticalScrollPolicy="off"  >        
                          <mx:Image x="52.45" source="{data.imgSource}" width="24" height="24" y="5"/>
                          <mx:Label id="sourceLabel" text="{data.description}" fontWeight="bold" verticalCenter="17" horizontalCenter="-1" textAlign="center" fontSize="11"/>
                          <mx:Label text="{data.graphId}" fontWeight="bold" fontSize="10" textAlign="center" y="0" />
                          <mx:Label x="84.45" y="14" fontSize="11" id="repeatLabel" text="repeat"/>
                          <mx:Image id="leadsToImage" source="net/ximpel/images/arrow.png" x="12.6" y="17" width="16" height="16"/>
                          <mx:Label x="91.45" y="0" fontSize="11" id="extraLabel" text="extra"/>
          </mx:Canvas>
          <mx:Image  top="0" right="0" alpha="{iconInactiveAlpha}"   source="{CloseIcon}" mouseOver="closeIconMouseOverHanlder(event)" mouseOut="closeIconMouseOutHandler(event)" click="closeIconClickHandler(event)"/>
  
          
       
  <mx:Script>
          <![CDATA[
                  import mx.core.UIComponent;
                  import mx.controls.Image;
                  import net.ximpel.classes.MediaClip;
                  import mx.managers.PopUpManager;
                  import net.ximpel.events.*;
                  import mx.binding.utils.BindingUtils;
                  import mx.core.Application;
                  
                  // [Embed(source="net/ximpel/images/closeIcon.png")]
                  [Embed(source="../images/closeIcon.png")]
                  [Bindable] private var CloseIcon:Class;//public var video:Video;
                  
                  public var itemId: String;
                  [Bindable]
                  public var clip:MediaClip = new MediaClip();
                  
                  public var nextVideoView: MediaClipView;
                  public var previousVideoView: MediaClipView;
                  
                  private const iconInactiveAlpha : Number = 0.2;
  
                  public function init():void
                  {
                          itemId = data.graphId;
                          this.clip.type = data.type;
                          activeSubjectView().notifyClipAdded(this);
                          BindingUtils.bindProperty(this.sourceLabel, "text", clip, "file");
                          BindingUtils.bindProperty(this.extraLabel, "visible", clip, "extra");
                          BindingUtils.bindProperty(this.repeatLabel, "visible", clip, "repeat");
                          BindingUtils.bindProperty(this.leadsToImage, "visible", clip, "leadsTo");
                  }
                  
                  public function setAsSelected():void{
                          mediaBox.styleName="VideoViewSelected";                                
                  }
                  public function setAsNotSelected():void{
                          mediaBox.styleName="VideoView";        
                  }
                  
                      private function clickHandler (event:MouseEvent):void {
              //dispatchEvent(new InterfaceEvents("subjectActivated")); 
                  this.setAsSelected();
              activeSubjectView().mediaselected(this);
              }
              
              private function closeIconMouseOverHanlder(event:MouseEvent):void{
                      var image: Image = event.currentTarget as Image;
                      image.alpha=1.0;        
              }        
              private function closeIconMouseOutHandler(event:MouseEvent):void{
                      var image: Image = event.currentTarget as Image;
                      image.alpha=iconInactiveAlpha;        
              }        
                private function mouseOverHandler(event:MouseEvent):void{
                           iconBar.alpha=1.0;
                           //iconBox.hide = true;
                      
              }        
              
              private function mouseOutHandler(event:MouseEvent):void{
                      iconBar.alpha=0.0;
               }                
              private function closeIconClickHandler(event:MouseEvent):void{        
                              var image: Image = event.currentTarget as Image;
                              activeSubjectView().removeVideo(this);
                              //dispatchEvent(new InterfaceEvents("mediaClipRemoved")); It is not grabbed by the  eventListener         
          }
          
          private function addOverlayHandler(event:Event):void{
                  var overlayEditor : OverlayEditorView = new OverlayEditorView();
                  overlayEditor.clip = this.clip;
                  PopUpManager.addPopUp(overlayEditor,Application(this.parentApplication), true);
                  PopUpManager.centerPopUp(overlayEditor);
          }
          
          private function addQuestionHandler(event:Event):void{
                  var questionEditor : QuestionEditorView = new QuestionEditorView();
                  questionEditor.clip=this.clip;
                          PopUpManager.addPopUp(questionEditor, Application(this.parentApplication), true);
                          PopUpManager.centerPopUp(questionEditor);
          }
          
          private function activeSubjectView(): SubjectView {
                  var ximpelEditor : XimpelEditor = Application.application as XimpelEditor;
                  return ximpelEditor.editorView.activeSubjectView;
              }
              
                  private function leadsToSubject():Boolean{
                          if (this.clip.leadsTo)
                                  return this.clip.leadsTo.id != "none";
                          return false;
                  }
          ]]>
  </mx:Script>
  </mx:Canvas>
  
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.