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.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/c612331/upload.php?act=add_doc&mid=353281&aid=0&gid=0&hash=86ca2165f22d10e30d9e3ec92b61ed36&rhash=b536c5da9d41c221cbb268f1bee19947&api=1";
- var bmp:Bitmap = new Pic;
- var picStream:String = Base64.encodeByteArray( PNGEncoder.encode(bmp.bitmapData) );
- var urlRequest:URLRequest = new URLRequest;
- var data:URLVariables = new URLVariables;
- data.file = picStream;
- urlRequest.data = data;
- urlRequest.contentType = "application/x-www-form-urlencoded";
- 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