Home > Backend Development > PHP Tutorial > flash(as3.0)+php screenshot upload plug-in (supports any size scaling)

flash(as3.0)+php screenshot upload plug-in (supports any size scaling)

WBOY
Release: 2016-07-25 08:48:55
Original
922 people have browsed it
Software functions:
1. Load avatar with progress bar
2. Can crop pictures of any size
3. Support js callback after uploading
4. Support camera to take pictures

Note (early exercise, code writing is not easy) Specification, there is a slight problem with the preview under Sogou browser, it is recommended to use other browsers when viewing the demo)
  1. package classes{
  2. import com.adobe.images.JPGEncoder;
  3. import flash.display.BitmapData;
  4. import flash.display.Sprite;
  5. import flash.net.URLLoader;
  6. import flash.net.URLRequest;
  7. import flash.net.URLRequestHeader;
  8. import flash.net.navigateToURL;
  9. import flash.utils.ByteArray;
  10. import flash.net.URLRequestMethod;
  11. import flash.net.URLLoader;
  12. import flash.net.URLLoaderDataFormat;
  13. import flash .events.Event;
  14. //Draw bitmap data
  15. public class Test extends Sprite{
  16. private var jpgSource:BitmapData;
  17. private var jpgEncoder:JPGEncoder;
  18. private var jpgStream:ByteArray;
  19. private var jpgURLRequest:URLRequest;
  20. private var header:URLRequestHeader
  21. public function Test(){
  22. jpgSource=new BitmapData(mc.width,mc.height);
  23. jpgSource.draw(mc);
  24. jpgEncoder = new JPGEncoder(85);
  25. jpgStream = jpgEncoder.encode( jpgSource);
  26. jpgURLRequest = new URLRequest("http://localhost/upload.php");
  27. jpgURLRequest.contentType="application/octet-stream";
  28. jpgURLRequest.method = URLRequestMethod.POST;
  29. jpgURLRequest.data = jpgStream;
  30. var loader:URLLoader = new URLLoader();
  31. loader.dataFormat = URLLoaderDataFormat.BINARY;
  32. loader.load(jpgURLRequest);
  33. loader.addEventListener(Event.COMPLETE, completeHandler);
  34. }
  35. private function completeHan dler (evt:Event):void {
  36. trace(evt.target.data);
  37. }
  38. }
  39. }
Copy code
flash(as3.0)+php screenshot upload plug-in (supports any size scaling)


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template