topical media & game development

talk show tell print

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

lib-flex-ximpel-editor-net-ximpel-classes-Subject.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-Subject implements IHasXMLRepresentation
          {
                  [Bindable]
                  public var id: String;
                  [Bindable]
                  public var description: String;
                  public var scores:Array;
                  public var media:Array;
                  [Bindable]
                  public var leadsTo:String;
                          
                  public function @ax-lib-flex-ximpel-editor-net-ximpel-classes-Subject()
                  {
                          id = new String();
                          id = "default";
                          description = new String();
                          description = "default description";
                          scores = new Array();
                          media = new Array();
                          leadsTo = null;
                  }
                  
                  public function addClip(_clip:MediaClip):void{
                          media.push(_clip);
                  }
                  public function removeClip(_clip:MediaClip):void{
                          var index : int = media.indexOf(_clip);
                          media.splice(index, 1);
                          trace(media.toString());                        
                  }
          
                  public function addScore(_score : Object):void{
                          scores.push(_score);
                  }
  
                  public function removeScore(_index : int):void{
                          scores.splice(_index,1);
                  }
                  public function toXML():XML 
                  {
                          var attributes:String = "name=\"" + id + "\"";
                          if(leadsTo && leadsTo != "none"){
                                  attributes = attributes + " leadsto=\"" + leadsTo + "\"";
                          }
                          var subject:XML =
                          <subject {attributes}>
                                  <longname>{description}</longname>
                          </subject>;
                          
                          for (var j:int = 0; j < scores.length; j++) {
                                          subject.appendChild(Score(scores[j]).toXML());
                          }
                          
                          var videosXML:XML =
                          <media></media>;
                          
                          for (var i:int = 0; i < media.length; i++) {
                                  if(media[i] is MediaClip){
                                          videosXML.appendChild(media[i].toXML());
                                  }
                          }
                          subject.appendChild(videosXML);
  
                          return subject;
                  }
          }
  }


(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.