Zurück   Flashforum > Flex und AIR > Adobe AIR

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 03-01-2012, 13:09   #1 (permalink)
Neuer User
 
Benutzerbild von option
 
Registriert seit: Aug 2006
Beiträge: 357
drag and drop

hallo,

weiss jemand wo man ein beispiel finden kann um ein bild in und aus einer Air app zu ziehen?

beste grüße
option
__________________
:-)
option ist offline   Mit Zitat antworten
Alt 31-01-2012, 09:26   #2 (permalink)
Kein Meister
 
Benutzerbild von DabelDirk
 
Registriert seit: Feb 2011
Ort: Zuhause. Näheres auf Anfrage.
Beiträge: 33
Hallo,

also bei meiner lokal installierten "Tour de Flex" gibt es da Beispiele dazu. Leider finde ich die nicht in der online Version der "Tour de Flex". Bei meiner lokalen Version steht da etwas von 713 Samples, bei der online Version nur 664. Die online Version ist V1.2.1, meine lokale V2.0. Keine Ahnung was die da machen, aber scheinbar wird die online Version nicht gepflegt.

Hier:
Tour de Flex | Adobe Flex Developer Center
Kannst du dir das installieren.
Bei mir gibt es da extra nen Menüpunkt "Air Applications/Air APIs and Techniques" und dort "Drag and Drop (2)".

Fallst Du es nicht findest hier noch den Code:
PHP-Code:
// DragIn.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" 
                       backgroundColor="#323232" styleName="plain" width="100%" height="100%">

    <fx:Script>
        import mx.managers.DragManager;
        import mx.core.IUIComponent;
    </fx:Script>
   
    <mx:nativeDragEnter>
        // Event handler for when something is dragged over to the WindowedApplication
        // Only allow files to be dragged in
        if (event.clipboard.hasFormat(ClipboardFormats.FILE_LIST_FORMAT))
        {
            var files:Array = event.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
            
            // only allow a single file to be dragged in
            if (files.length == 1)
            {
                DragManager.acceptDragDrop(event.currentTarget as IUIComponent);
                setStyle("backgroundColor", 0xccccff);
            }
        }
    </mx:nativeDragEnter>
    
    <mx:nativeDragExit>
        // Event handler for when the drag leaves the WindowedApplication
        setStyle("backgroundColor", 0x323232);
    </mx:nativeDragExit>
    
    <mx:nativeDragDrop>
        // Event handler for when a dragged item is dropped on the WindowedApplication
        var arr:Array = event.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
        startImage.source = (arr[0] as File).url;
    </mx:nativeDragDrop>
    
    
    <mx:ViewStack id="startVS" width="100%" height="100%" creationPolicy="all">
        <mx:Canvas width="100%" height="100%">
            <mx:Text verticalCenter="0" horizontalCenter="0" color="white">
                <mx:htmlText><![CDATA[<font size="20"><b>Drag an image here</b></font>]]></mx:htmlText>
            </mx:Text>
        </mx:Canvas>
        <mx:Canvas width="100%" height="100%">
            <mx:Image id="startImage" width="100%" height="100%" horizontalAlign="center" verticalAlign="middle" complete="startVS.selectedIndex = 1;"/>
        </mx:Canvas>
    </mx:ViewStack>

</s:WindowedApplication>
PHP-Code:
// DragOut.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" 
                       backgroundColor="#323232" styleName="plain" width="100%" height="100%">
    <fx:Script>
            [Bindable]private var logo:File = new File("app:/air-logo.jpg");
            
            [Embed("air-logo-icon.jpg")]
            private var logoIconClass:Class;
            
        
    </fx:Script>
    <s:VGroup horizontalAlign="center">
        <s:Label text="Drag the image out of the application" color="white"/>
        
        <mx:Image id="image" source="{logo.url}" width="90%" height="90%" horizontalAlign="center" verticalAlign="middle">
            <mx:mouseDown>
                // Event handler which begins the drag
                
                // Allow the image to be dragged as either a file or a bitmap
                var transfer:Clipboard = new Clipboard();
                transfer.setData(ClipboardFormats.BITMAP_FORMAT, Bitmap(image.content).bitmapData);
                transfer.setData(ClipboardFormats.FILE_LIST_FORMAT, new Array(logo), false);
                
                // only allow the file to be copied
                var dragOptions:NativeDragOptions = new NativeDragOptions();
                dragOptions.allowMove = false;
                dragOptions.allowCopy = true;
                dragOptions.allowLink = false;
                
                // create an icon to display when dragging
                var iconBitmapData:BitmapData = (new logoIconClass() as Bitmap).bitmapData;
                
                // begin the drag
                NativeDragManager.doDrag(this, transfer, iconBitmapData, null, dragOptions);
            </mx:mouseDown>
        </mx:Image>
    </s:VGroup>
</s:WindowedApplication>
Have Fun
__________________
Grüße,
Dirk
dabelstein.com

Geändert von DabelDirk (31-01-2012 um 09:59 Uhr)
DabelDirk ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Drag'n'Drop-Objekt bei Drop "ausrollen" lassen geegle Flash Einsteiger 4 25-03-2008 20:30
Drag & Drop: Drop nicht im .swf schmidtpublic_m ActionScript 1 4 14-07-2005 10:24
Drag and Drop durch verschiedene MCs leider nur Press Drag & press Drop MF_ ActionScript 1 5 12-07-2004 11:11
Drop Target Problem / Drag&Drop bewerber2 Flash 4 und Flash 5 2 05-01-2004 16:59
drag and drop buster007 Flash 4 und Flash 5 5 18-11-2001 18:59


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:47 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele