topical media & game development

talk show tell print

lib-flex-ximpel-editor-net-ximpel-classes-MediaClip.ax

lib-flex-ximpel-editor-net-ximpel-classes-MediaClip.ax (swf ) [ flash ] flex


  /*
      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.
  
  */
  package net.ximpel.classes
  {
          
          public class @ax-lib-flex-ximpel-editor-net-ximpel-classes-MediaClip implements IHasXMLRepresentation
          {
                  [Bindable]
                  public var file:String;
                  [Bindable]
                  public var repeat:Boolean;
                  [Bindable]
                  public var extra:Boolean;
                  [Bindable]
                  public var branchQuestion:String;
                  [Bindable]                
                  public var overlays:Array;
                  [Bindable]                
                  public var question:Question;
                  [Bindable]                
                  public var leadsTo:Subject;
                  [Bindable]
                  public var type:String;
                  
                  public function @ax-lib-flex-ximpel-editor-net-ximpel-classes-MediaClip (_file:String = null, _repeat:Boolean = false, _extra:Boolean = false, _branchQuestion:String = null, 
                                                                    _overlays:Array = null, _question:Question = null, _leadsTo : String = null)
                  {
                          
                          file = (_file == null ? new String("filename") : _file);
                          //repeat = _repeat;
                          //extra  =  _extra;
                          //branchQuestion = (_branchQuestion == null ? new String("") : _branchQuestion);
                          question = (_question == null ? new Question() : _question);
                          overlays = (_overlays == null ? new Array() : _overlays);
                          //leadsTo = (_leadsTo == null ? new String() : _leadsTo);        
                          
                  }
                  
                  public function addOverlay():void{
                          var extendedOverlay : ExtendedOverlay = new ExtendedOverlay();
                          overlays.push(extendedOverlay);
                          }
                  
                  
                  public function toXML():XML
                  {
                          var attributes:String = "file=\"" + file + "\"";
                          
                          if(repeat){
                                  attributes = attributes + " repeat=\"" + String(repeat) + "\"";
                          }
                          
                          if(type){
                                  attributes = attributes + " type=\"" + String(type) + "\"";
                          }
                          
                          if(extra){
                                  attributes = attributes + " extra=\"" + String(extra) + "\"";
                          }
                          
                          if(leadsTo){
                                  attributes = attributes + " leadsto=\"" + leadsTo.id + "\"";
                          }
                          var mediaClip:XML =
                          <item {attributes}>
                          </item>;
                          
                          if (branchQuestion != null && branchQuestion !="") {
                                  var branchQuestionXML:XML = 
                                  <branchquestion>{branchQuestion}</branchquestion>;
                                  mediaClip.appendChild(branchQuestionXML);
                          }
                          
                          var overlaysXML:XML = 
                          <overlays>
                          </overlays>;
                          
                          for (var i:int = 0; i < overlays.length; i++) {
                                  if((overlays[i] is DefaultOverlay) || (overlays[i] is ExtendedOverlay)){
                                          overlaysXML.appendChild(overlays[i].toXML());
                                  }
                          }
                          if(overlaysXML.hasComplexContent()){
                                  mediaClip.appendChild(overlaysXML);
                          }
                          
                          if(question != null){
                                  
                                  if (question.questionText){
                                          var questionTextXML:XML = 
                                          <question>{question.questionText}</question>;
                                          mediaClip.appendChild(questionTextXML);
                                          
                                          var questionRightAnswerXML:XML = 
                                          <rightanswer>{String(question.rightAnswer)}</rightanswer>;
                          
                                          mediaClip.appendChild(questionRightAnswerXML);
                                  }
                          }
  
                          return mediaClip;
                  }
  
                  
                  public function addNextClip(_clip:@ax-lib-flex-ximpel-editor-net-ximpel-classes-MediaClip):void{
                          //nextClip = _clip;
                  }
                  
                  public function removeNextClip():void{
                          //nextClip = null;
                  }
                  
                  public function addPreviousClip(_clip:@ax-lib-flex-ximpel-editor-net-ximpel-classes-MediaClip):void{
                          //nextClip = _clip;
                  }
                  
                  public function removePreviousClip():void{
                          //nextClip = null;
                  }
                  
                  public function removeOverlay(overlay:ExtendedOverlay):void{
                          this.overlays.splice(overlays.indexOf(overlay),1);
                  }
                  
                  public function hasQuestion():Boolean{
                          return (question!=null);
                  }
                  
                  public function hasOverlays():Boolean{
                          return (overlays!=null);
                  }
                  
  /*		public function addOverlay(_overlay:OverlayCel):void
                  {
                          if (!overlays){
                                  overlays = new Array();
                          }
                          overlays.push(_overlay);                                
                  }*/
                  
                  public function addQuestion(_question:Question):void
                  {
                          if (_question) {
                                  this.question=_question;
                          }
                  }
  
          }
  }


(C) Æliens 19/08/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.