topical media & game development
lib-flex-ximpel-editor-net-ximpel-components-ToolPanel.mx
lib-flex-ximpel-editor-net-ximpel-components-ToolPanel.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"
width="224"
title="Media tool panel"
creationComplete="init();"
verticalScrollPolicy="off"
horizontalAlign="center">
<mx:Grid id="grid" width="100%" height="100%" verticalScrollPolicy="off" horizontalAlign="center" />
<mx:HTTPService id="httpService"
url="config/toolpanelitems.xml"
result="resultHandler(event)"
fault="faultEvent(event)"/>
<mx:Script>
<![CDATA[
import mx.containers.GridItem;
import mx.containers.GridRow;
import mx.rpc.events.FaultEvent;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.controls.Image;
import mx.core.DragSource;
import mx.managers.DragManager;
private static const numColumns : int = 3;
[Bindable]
// [Embed("net/ximpel/images/genericIcon.png")]
[Embed("../images/genericIcon.png")]
private var genericIcon:Class;
[Bindable]
private var toolElements : ArrayCollection;
private function init ():void {
httpService.send();
}
private function iconImageWithItem(item : Object):Image{
var image : Image = new Image();
image.toolTip = item.tooltiptext;
image.source = "net/ximpel/images/videoIcon.png";
return image;
}
private function buildToolPanel():void{
var gridRow : GridRow;
var gridItem : GridItem;
var image : Image;
var toolPanelItem : ToolPanelItem;
var currentColumn : int = 0;
for (var item : Object in toolElements){
if (currentColumn == 0){
gridRow = new GridRow();
grid.addChild(gridRow);
}
currentColumn = (currentColumn == numColumns - 1 ? 0 :currentColumn +1);
toolPanelItem = new ToolPanelItem();
toolPanelItem.initWithVector(toolElements.getItemAt(int(item)));
gridItem = new GridItem();
gridItem.addChild(toolPanelItem);
gridRow.addChild(gridItem);
}
}
private function resultHandler(event:ResultEvent):void {
toolElements = event.result.toolpanelitems.toolpanelitem;
buildToolPanel();
}
private function faultEvent(event:FaultEvent):void{
trace ("Could not build panel");
}
private function dragIt(event:MouseEvent, value:uint):void
{
var img:Image = event.currentTarget as Image;
var dragInitiator:Image = event.currentTarget as Image;
var dragSource:DragSource = new DragSource();
var dragProxy:Image = new Image();
dragProxy.source = img.source;
switch (value)
{
case 0:
dragSource.addData(img, 'videoClip');
break;
case 1:
dragSource.addData(img, 'audioClip');
break;
}
DragManager.doDrag(dragInitiator, dragSource, event, dragProxy);
}
]]>
</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.