/*
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 .
Javier Quevedo Fernández 05-2009.
*/
package net.ximpel.classes
{
public class 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 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 =
{description}
;
for (var j:int = 0; j < scores.length; j++) {
subject.appendChild(Score(scores[j]).toXML());
}
var videosXML:XML =
;
for (var i:int = 0; i < media.length; i++) {
if(media[i] is MediaClip){
videosXML.appendChild(media[i].toXML());
}
}
subject.appendChild(videosXML);
return subject;
}
}
}