Is it possible to drag and drop from/to outside a Flash applet with JavaScript?

前端 未结 6 1303
无人共我
无人共我 2021-01-05 17:09

Let\'s say I want a web page that contains a Flash applet and I\'d like to drag and drop some objects from or to the rest of the web page, is this at all possible?

B

6条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-05 17:50

    DISCLAIMER I haven't tested this code at all, but the idea should work. Also, this only handles the dragging to a flash movie.

    Here's some Actionscript 3.0 code which makes use of the ExternalInterface class.

    import flash.display.Sprite;
    import flash.external.ExternalInterface;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    
    if (ExternalInterface.available) {
      ExternalInterface.addCallback("handleDroppedImage", myDroppedImageHandler);
    }
    
    private function myDroppedImageHandler(url:String, x:Number, y:Number):void {
    
      var container:Sprite = new Sprite();
      container.x = x;
      container.y = y;
      addChild(container);
    
      var loader:Loader = new Loader();
      var request:URLRequest = new URLRequest(url);
      loader.load(request);
    
      container.addChild(loader);
    }
    

    Here's the HTML/jQuery code

    
    
      XHTML 1.0 Transitional Template
      
      
      
    
    
    
      drag me
    
      

提交回复
热议问题