topical media & game development
lib-flex-ximpel-editor-net-ximpel-components-EditorView.mx
lib-flex-ximpel-editor-net-ximpel-components-EditorView.mx
(swf
)
[ flash
]
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:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
left="245"
right="5"
height="90%"
title="Editor"
dragDrop="dragDropHandler(event);"
dragEnter="dragEnterHandler(event);"
creationComplete="init();">
<mx:Canvas width="100%" height="100%" styleName="EditCanvas" backgroundColor="#FFFFFF">
<mx:TabNavigator horizontalCenter="0" id="tabNavigator" fontSharpness="10" x="4.5" y="5" width="100%" height="100%" change="childIndexChangeHandler(event)">
<mx:Canvas id="startCanvas" label="Welcome" width="100%" height="100%">
<mx:TextArea width="100%" height="100%">
<mx:htmlText><![CDATA[
Welcome to <font color="#FF0000">Vixie</font>, the Ximpel playlist editor for the Ximpel Interactive Media Player.
You can begin editing your playlist by simply clicking the button <b>Add subject</b>.
If you have any questions or doubts please contact us at <a href="mailto:support@ximpel.net">our support email</a>.]]></mx:htmlText>
</mx:TextArea>
</mx:Canvas>
</mx:TabNavigator>
</mx:Canvas>
<mx:Script>
<![CDATA[
import mx.controls.ComboBox;
import mx.events.DragEvent;
import mx.managers.DragManager;
import mx.containers.Canvas;
import net.ximpel.classes.*;
import net.ximpel.events.InterfaceEvents;
import flash.utils.*;
[Bindable]
public var interactiveVideo:InteractiveVideo = new InteractiveVideo();
public var activeSubjectView : SubjectView;
public var activeMedia : Object;
[Bindable]
public var propertiesPanel : PropertiesPanel;
public var subjectForm : SubjectForm = new SubjectForm();
public var mediaClipForm : MediaClipForm = new MediaClipForm();
public var subjectCount:int =0;
public function init():void{
}
private function dragDropHandler(event:DragEvent):void {
addSubject();
}
private function dragEnterHandler(event:DragEvent):void {
if (event.dragSource.hasFormat("subject"))
{
DragManager.acceptDragDrop(EditorView(event.currentTarget));
}
}
public function addSubject():void {
if (subjectCount == 0)
{
tabNavigator.removeChild(startCanvas);
}
var canvas:Canvas = new Canvas();
tabNavigator.addChild(canvas);
var subjectView:SubjectView = new SubjectView();
subjectView.subject.id="Subject"+subjectCount;
canvas.addChild(subjectView);
canvas.label=subjectView.subject.id;
tabNavigator.selectedIndex = tabNavigator.numChildren-1;
interactiveVideo.addSubject(subjectView.subject);
subjectForm.removeEventListener(InterfaceEvents.SUBJECT_FORM_CHANGED, subjectFormChangedHandler);
setAsActiveSubjectView(subjectView);
subjectForm.addEventListener(InterfaceEvents.SUBJECT_FORM_CHANGED, subjectFormChangedHandler);
subjectView.addEventListener(InterfaceEvents.SUBJECT_ACTIVATED, subjectActivatedHandler);
subjectView.addEventListener(InterfaceEvents.MEDIA_ACTIVATED, mediaActivatedHandler);
subjectCount++;
}
public function removeCurrentSubject():void{
if (subjectCount > 0){
subjectCount--;
var currentSubjectView : SubjectView = tabNavigator.selectedChild.getChildAt(0) as SubjectView;
interactiveVideo.removeSubject(currentSubjectView.subject);
tabNavigator.removeChild(tabNavigator.selectedChild);
if (subjectCount == 0)
tabNavigator.addChild(startCanvas);
}
}
private function setAsActiveMedia(media : Object):void
{
if (media == activeMedia)
return;
activeMedia = media;
propertiesPanel.propertiesCanvas.removeAllChildren();
var className : String = flash.utils.getQualifiedClassName(activeMedia);
if (className == "net.ximpel.components::MediaClipView")
{
var clipView : MediaClipView = activeMedia as MediaClipView;
propertiesPanel.propertiesCanvas.addChild(mediaClipForm);
var subject : Subject = new Subject();
mediaClipForm.updateClip(clipView.clip, interactiveVideo.subjects);
}
}
public function setAsActiveSubjectView(subjectView:SubjectView): void
{
if (activeSubjectView == subjectView)
return;
activeSubjectView = subjectView;
propertiesPanel.propertiesCanvas.removeAllChildren();
propertiesPanel.propertiesCanvas.addChild(subjectForm);
subjectForm.updateForm(subjectView.subject, interactiveVideo.subjects);
subjectForm.subjectView=subjectView;
}
private function subjectFormChangedHandler(event:InterfaceEvents):void
{
subjectForm.updateSubject();
activeSubjectView.updateInfo();
}
private function mediaActivatedHandler (event:InterfaceEvents):void {
var currentSubjectView : SubjectView = event.currentTarget as SubjectView;
var mediaView : MediaClipView = currentSubjectView.currentMedia as MediaClipView;
setAsActiveMedia(mediaView);
}
private function subjectActivatedHandler(event:InterfaceEvents):void
{
var currentSubjectView : SubjectView = event.currentTarget as SubjectView;
setAsActiveSubjectView(currentSubjectView);
}
private function childIndexChangeHandler(event:Event):void
{
var _tabNavigator:TabNavigator = event.currentTarget as TabNavigator;
var _canvas : Canvas = tabNavigator.selectedChild as Canvas;
var _subjectView : SubjectView = _canvas.getChildAt(0) as SubjectView;
subjectForm.removeEventListener(InterfaceEvents.SUBJECT_FORM_CHANGED, subjectFormChangedHandler);
setAsActiveSubjectView(_subjectView);
subjectForm.addEventListener(InterfaceEvents.SUBJECT_FORM_CHANGED, subjectFormChangedHandler);
}
]]>
</mx:Script>
</mx:TitleWindow>
(C) Æliens
18/6/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.