topical media & game development

talk show tell print

lib-flex-ximpel-editor-net-ximpel-components-ToolPanelItem.mx

lib-flex-ximpel-editor-net-ximpel-components-ToolPanelItem.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:Image xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init();"
           mouseDown="dragIt(event)">
          <mx:Script>
                  <![CDATA[
                          import mx.core.DragSource;
                          import mx.managers.DragManager;
                          [Bindable]
                          public var type : String;
                          public var itemName : String;
                          public var description : String;
                          public var smallIcon : String;
                          
  
                          [Bindable]
                          // [Embed("net/ximpel/images/genericIcon.png")]
                          [Embed("../images/genericIcon.png")]
                           private var GenericIcon:Class;
                          
                          public function init():void{
          
                          }  
                          public function initWithVector(vector : Object):void{
                                  this.type = vector.type;
                                  description = vector.description;
                                  this.toolTip=vector.tooltiptext;
                                  this.source = vector.toolpanelicon;
                                  this.smallIcon = vector.viewicon;
  
                          }
                          private function dragIt(event:MouseEvent):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();
                  if (img.source is String)
                          dragProxy.source = GenericIcon;
                  else
                          dragProxy.source = img.source;
                          
                  dragSource.addData(img, this.type);                
                  dragSource.addData(img, this.smallIcon);
                  
                         DragManager.doDrag(dragInitiator, dragSource, event, dragProxy);
              }                        
                  ]]>
          </mx:Script>
  </mx:Image>
  


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