Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import adobe.utils.CustomActions;
- import com.adobe.images.PNGEncoder;
- import com.greensock.events.LoaderEvent;
- import com.greensock.loading.DataLoader;
- import com.hurlant.util.Base64;
- import flash.display.Bitmap;
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.net.URLRequest;
- import flash.net.URLRequestMethod;
- import flash.net.URLVariables;
- import flash.utils.ByteArray;
- public class Main extends Sprite
- {
- [Embed(source="../lib/pic.jpg")]
- public static var Pic:Class;
- public function Main():void
- {
- if (stage) init();
- else addEventListener(Event.ADDED_TO_STAGE, init);
- }
- private function init(e:Event = null):void
- {
- removeEventListener(Event.ADDED_TO_STAGE, init);
- // entry point
- var url:String = "https://pu.vk.com/c610116/upload.php?act=add_doc&mid=353281&aid=0&gid=0&hash=ac08e06399d784ac0ef36a0331a456f5&rhash=65df5b10ce6239cef0af349f98ac574e&api=1";
- var bmp:Bitmap = new Pic;
- var picStream:ByteArray = PNGEncoder.encode(bmp.bitmapData) ;
- var urlRequest:URLRequest = new URLRequest;
- var data:URLVariables = new URLVariables;
- data.file = picStream;
- urlRequest.data = data;
- urlRequest.method = URLRequestMethod.POST;
- urlRequest.contentType = "multipart/form-data";
- urlRequest.url = url;
- var dataLoader:DataLoader = new DataLoader(urlRequest, { onComplete: onDataComplete } );
- dataLoader.load();
- }
- private function onDataComplete(e:LoaderEvent):void
- {
- trace(e.currentTarget.content);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement