Problem with Native Drag and Drop like Flexlib Docker - But i want “Native Docker” for Adobe Native Window and Canvas or Loader???? 
Posted: 04 September 2015 04:36 PM   [ Ignore ]
Rank
Joined  2015-09-04
Total Posts:  1
New Member

Helllo Sirs & Ladies,

I want to tell about old Flexlib Docker from GoogleCode. I try with Adobe Air like same NativeWindow as docked mode as Canvas but it can not work :(

How do i fix this?

TestAirDockedWindow.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                        
xmlns:mx="library://ns.adobe.com/flex/mx"
                        
xmlns:ns1="*"
                        
creationComplete="onCreatingComplete(event)" layout="absolute">
    <
fx:Script>
        <!
[CDATA[
            import mx
.events.FlexEvent;
            
            
import net.sourceskyboxer.utils.ExtendedNativeWindow;
            
            private var 
_dockerInitOption:NativeWindowInitOptions;
            private var 
_dockerWindow:ExtendedNativeWindow;
            private var 
_dockerContent:DockerContent;
            
            protected function 
onCreatingComplete(event:FlexEvent):void
            {
                
                
//register for the drag enter event
                
addEventListener(NativeDragEvent.NATIVE_DRAG_ENTERonDragIn);
                
                
//register for the drag drop event
                
addEventListener(NativeDragEvent.NATIVE_DRAG_DROPonDragDrop);
            
}
            
            
private function onDragIn(e:NativeDragEvent):void
            {
                
if(e.clipboard.hasFormat(ClipboardFormats.URL_FORMAT))
                
{
                    _dockerContent 
= new DockerContent();
                    var 
_dragger:Canvas _dockerContent.dragger;
                    
_dragger.addChild(_dockerCanvas);
                    
                    
_dockerWindow null;
                
}
                
            }
            
            
private function onDragDrop(e:NativeDragEvent):void
            {
                
var obj:DisplayObject e.clipboard.hasFormat(ClipboardFormats.URL_FORMAT) as DisplayObject;
                var 
i:int 1;
                
obj _dockerCanvas.getChildAt(i);
            
}
            
            
protected function doubeClick(event:MouseEvent):void
            {
                
if(event.target.hasFormat(ClipboardFormats.URL_FORMAT))
                
{
                    _dockerContent 
= new DockerContent();
                    var 
_dragger:Canvas _dockerContent.dragger;
                    
_dragger.addChild(_dockerCanvas);
                    
                    
_dockerWindow null;
                
}
            }
            
            
protected function openDockerWindow(event:MouseEvent):void
            {
                _dockerInitOption 
= new NativeWindowInitOptions();
                
_dockerInitOption.type NativeWindowType.UTILITY;
                
                
_dockerWindow = new ExtendedNativeWindow(_dockerInitOption);
                
_dockerWindow.width _dockerWindow.height 200;
                
_dockerWindow._dockerWindow.150;
                
_dockerContent = new DockerContent();
                
_dockerWindow.addChildControls(_dockerContent);
                
_dockerWindow.activate();
            
}
            
        ]]
>
    </
fx:Script>
    <
fx:Declarations>
        <!-- 
Platzieren Sie nichtvisuelle Elemente (z. BDiensteWertobjektehier -->
    </
fx:Declarations>
    <
mx:Canvas id="_dockerCanvas" left="10" right="10" top="39" bottom="10">
    </
mx:Canvas>
    <
mx:Button left="10" top="10" label="Open Custom DockerWindow"
               
click="openDockerWindow(event)"/>
</
mx:WindowedApplication>

DockerContent.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009" 
           
xmlns:mx="library://ns.adobe.com/flex/mx" width="200" height="200">
    <
fx:Declarations>
        <!-- 
Platzieren Sie nichtvisuelle Elemente (z. BDiensteWertobjektehier -->
    </
fx:Declarations>
    <
mx:Label horizontalCenter="0" text="Test Docker " verticalCenter="0"/>
    <
mx:Canvas id="dragger" left="10" right="10" top="10" height="20" backgroundColor="#898989">
    </
mx:Canvas>
</
mx:Canvas>

ExtendedNativeWindow.as

package net.sourceskyboxer.utils
{
    import flash
.display.NativeWindow;
    
import flash.display.NativeWindowInitOptions;
    
import flash.events.Event;
    
import mx.events.*;
    
import mx.managers.WindowedSystemManager;
    
import mx.core.UIComponent;
    
    
[Event(name="creationComplete"type="mx.events.FlexEvent")
    
    
public class ExtendedNativeWindow extends NativeWindow
    {
        
private var _systemManager:WindowedSystemManager;
        private var 
_content:UIComponent;
        
        public function 
ExtendedNativeWindow(initOptions:NativeWindowInitOptions null)
        
{
            
//* Call the base class constructor
            
super(initOptions);
            
//* Add in a listener for the Activate event - this is where we add in the content
            
addEventListener(Event.ACTIVATEwindowActivateHandler);
            
//* Add in a close listener so we can tidy up when the window closes
            
addEventListener(Event.CLOSEcloseWindowHandler);
            
        
}
        
        
//* Custom function to allow the content to be passed into the window
        
public function addChildControls(control:UIComponent):void 
        {
            _content 
control;    
        
}
        
        
//* This handler actually adds the content to the NativeWindow
        
private function windowActivateHandler(event:Event):void 
        {
            
//* Process the event
            
event.preventDefault();
            
event.stopImmediatePropagation();
            
removeEventListener(Event.ACTIVATEwindowActivateHandler);
            
            
//* Create the children and add an event listener for re-sizing the window
            
if(stage
            
{
                
//* create a WindowedSystemManager to hold the content
                
if(!_systemManager
                
{
                    
//* Add an event listener for closing the window
                    
_content.addEventListener(CloseEvent.CLOSEcontentCloseHandler);
                    
//*    Create a system manager
                    
_systemManager = new WindowedSystemManager(_content);
                
}
                
                
//* Add the content to the stage
                
stage.addChild(_systemManager);
                
                
//* Dispatch a creation complete event
                
dispatchEvent(new FlexEvent(FlexEvent.CREATION_COMPLETE));
                
                
//* Add in a resize event listener
                
stage.addEventListener(Event.RESIZEwindowResizeHandler);
            
}
        }
        
        
//* Resizes the content in response to a change in size
        
private function windowResizeHandler(event:Event):void 
        {
            _content
.width stage.stageWidth;
            
_content.height stage.stageHeight;
        
}

        
//* Receives a close event from the NativeWindow content
        
private function contentCloseHandler(event:Event):void
        {
            this
.close();
        
}
        
        
//* Tidy everything up when the window closes
        
private function closeWindowHandler(event:Event):void 
        {
            removeEventListener
(Event.RESIZEwindowResizeHandler);
            
_systemManager.removeChild(_content);
            
stage.removeChild(_systemManager);
            
_content null;
            
_systemManager null;
        
}
    }
}

You know like SketchUp 2015 Toolbars and Microsoft Office Toolbars docked and windowed.

Thanks for answer i hope they know how do i dock nativewindow with Air Application???

Profile