Flash player 10 previews and uploads local images.

Source: Internet
Author: User

Take notes

Try flash cs4. The player of cs3 won't work.

Import ~~~

 

Var file: FileReference = new FileReference ();
Var loader: Loader = new Loader ();
Liulan. addEventListener (MouseEvent. CLICK, onClick );
Function onClick (event: MouseEvent): void {
File. browse ([new FileFilter ("Images (*. jpg ;*. png ;*. gif )","*. jpg ;*. png ;*. gif ")]);
File. addEventListener (Event. SELECT, onSelect );
}
Function onSelect (event: Event): void {
File. load ();
File. addEventListener (Event. COMPLETE, onComplete );
FileName. text = file. name;
}

Function onComplete (event: Event): void {
Loader. loadBytes (file. data );
Loader. contentLoaderInfo. addEventListener (Event. COMPLETE, onComplete2 );
}
Var bitmap: Bitmap;
Function onComplete2 (event: Event): void {
/* 1. if (bitmap! = Null)
{
RemoveChild (bitmap );
}
Loader. width = stage. stageWidth;
Loader. height = stage. stageHeight;
Var container: Sprite = new Sprite ();
Container. addChild (loader );
Var BMP data: BitmapData = new BitmapData (container. width, container. height );
BMP data. draw (container );
Bitmap = new Bitmap (BMP data );
AddChildAt (bitmap, 0 )*/

If (bitmap! = Null)
{
RemoveChild (bitmap );
}
Bitmap = event.tar get. content as Bitmap;
Bitmap. width = stage. stageWidth;
Bitmap. height = stage. stageHeight;
AddChildAt (bitmap, 0 );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.