Advertisement
sanych_dv

Untitled

Feb 14th, 2015
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.     import adobe.utils.CustomActions;
  4.     import com.adobe.images.PNGEncoder;
  5.     import com.greensock.events.LoaderEvent;
  6.     import com.greensock.loading.DataLoader;
  7.     import com.hurlant.util.Base64;
  8.     import flash.display.Bitmap;
  9.     import flash.display.Sprite;
  10.     import flash.events.Event;
  11.     import flash.net.URLRequest;
  12.     import flash.net.URLVariables;
  13.     import flash.utils.ByteArray;
  14.    
  15.  
  16.    
  17.  
  18.     public class Main extends Sprite
  19.     {
  20.        
  21.          [Embed(source="../lib/pic.jpg")]
  22. public static var Pic:Class;
  23.        
  24.         public function Main():void
  25.         {
  26.             if (stage) init();
  27.             else addEventListener(Event.ADDED_TO_STAGE, init);
  28.         }
  29.        
  30.         private function init(e:Event = null):void
  31.         {
  32.             removeEventListener(Event.ADDED_TO_STAGE, init);
  33.             // entry point
  34.            
  35.            
  36.         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";
  37.        
  38.         var bmp:Bitmap = new Pic;
  39.         var picStream:String = Base64.encodeByteArray( PNGEncoder.encode(bmp.bitmapData) );
  40.        
  41.         var urlRequest:URLRequest = new URLRequest;
  42.         var data:URLVariables = new URLVariables;
  43.        
  44.         data.file = picStream;
  45.        
  46.         urlRequest.data = data;
  47.         urlRequest.contentType = "application/x-www-form-urlencoded";
  48.        
  49.        
  50.         urlRequest.url = url;
  51.        
  52.         var dataLoader:DataLoader = new DataLoader(urlRequest, { onComplete: onDataComplete } );
  53.         dataLoader.load();
  54.        
  55.        
  56.         }
  57.        
  58.         private function onDataComplete(e:LoaderEvent):void
  59.         {
  60.             trace(e.currentTarget.content);
  61.         }
  62.        
  63.     }
  64.    
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement