/* 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_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 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 = ; if (branchQuestion != null && branchQuestion !="") { var branchQuestionXML:XML = {branchQuestion}; mediaClip.appendChild(branchQuestionXML); } var overlaysXML:XML = ; 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.questionText}; mediaClip.appendChild(questionTextXML); var questionRightAnswerXML:XML = {String(question.rightAnswer)}; mediaClip.appendChild(questionRightAnswerXML); } } return mediaClip; } public function addNextClip(_clip:lib_flex_ximpel_editor_net_ximpel_classes_MediaClip):void{ //nextClip = _clip; } public function removeNextClip():void{ //nextClip = null; } public function addPreviousClip(_clip: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; } } } }