Jump to content
Fórum Script Brasil
  • 0

Aplicar Drag Em As


claudio Manoel

Question

Olá,

Tenho um arquivo as que é usado em um .fla, ele faz o upload da imagem da maquina para tela, preciso aplicar drag na imagem que recebe o upload, pra arrastar ela na tela,

tentei vaias coisas mas não rolou, se alguém souber como me ajudar abaixo tem o script que tenho.

Nesse link tem algumas coisaas sobre drag, o problema é que não sei juntar os dois scripts;

http://gestureworks....tutorials/drag/

aqui é possivel fazer download do fla que tenho

http://forum.wmonline.com.br/index.php?app...attach_id=10648

package {

import flash.display.Sprite;

import flash.events.MouseEvent;

import flash.net.*;

import flash.display.*;

import flash.events.*;

import flash.utils.ByteArray;

import flash.net.URLRequest;

import flash.net.URLLoader;

public class uploadImage extends Sprite

{

private var jagFileRefSave:FileReference = new FileReference();

private var loader:Loader = new Loader();

private var imagesFilter:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png");

private var textFilter:FileFilter = new FileFilter("Text Files (*.php,*.xml)", "*.php; *.xml");

private var imgContainer:ImgContainer;

private var allTypes:Array;

private var UrlRequest:URLRequest;

public function uploadImage()

{

super();

allTypes = new Array(imagesFilter, textFilter);

UrlRequest = new URLRequest("uploader_script.php");

upload_Image.addEventListener(MouseEvent.CLICK,onclickSave);

upload_btn.addEventListener(MouseEvent.CLICK, uploadVars);

//jagFileRefSave.addEventListener(ProgressEvent.PROGRESS, progressHandler);

}

private function onclickSave(e:MouseEvent):void{

file_name.text = "";

file_size.text = "";

if(getChildByName("imgContainer") != null)

{

removeChild(getChildByName("imgContainer"));

}

jagFileRefSave.browse(allTypes);

jagFileRefSave.addEventListener(Event.SELECT, selectedFile);

}

private function selectedFile(e:Event):void

{

fileDisplay_txt.text = jagFileRefSave.name;

jagFileRefSave.load();

if((jagFileRefSave.type == ".php") || (jagFileRefSave.type == ".xml"))

{

file_name.text = "Selected file name is : "+jagFileRefSave.name;

file_size.text = "Selected file size is : "+(jagFileRefSave.size/1024)+" KB";

}

else

{

jagFileRefSave.addEventListener(Event.COMPLETE, loaded);

}

}

private function uploadVars(e:MouseEvent):void

{

if(fileDisplay_txt.text != "")

{

jagFileRefSave.upload(UrlRequest);

status_txt.text = jagFileRefSave.name + " has been uploaded.";

fileDisplay_txt.text = "";

}

}

private function loaded(e:Event):void{

var rawBytes:ByteArray = jagFileRefSave.data;

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getBitmapData)

loader.loadBytes(rawBytes);

}

private function getBitmapData(e:Event):void

{

imgContainer = new ImgContainer();

imgContainer.name = "imgContainer";

imgContainer.addChild(loader);

imgContainer.x = stage.stageWidth/2 - imgContainer.width/2;

imgContainer.y = stage.stageHeight/4;

addChild(imgContainer);

}

}

}

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

imgContainer.addEventListener( MouseEvent.MOUSE_DOWN, handlerMouseDown );
imgContainer.addEventListener( MouseEvent.MOUSE_UP, handlerMouseUp );

private function handlerMouseDown( e:MouseEvent ):void
{
     imgContainer.startDrag();
}

private function handlerMouseUp( e:MouseEvent ):void
{
     imgContainer.stopDrag();
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...