FLASH implement ASP. net mvc upload --- Flash, mvc --- flash

Source: Internet
Author: User

FLASH implement ASP. net mvc upload --- Flash, mvc --- flash

Let's take a look at the overall idea. The entire upload is at the entrance of the flash button.


Create Flash, add a button, and name it btn


Add class main.

Package {import flash. display. *; import flash. events. *; import flash.net. *; import flash. ui. *; import flash. external. externalInterface; public class main extends Sprite {public var btn: SimpleButton; private var uid: String; private var jid: String; private var sn: String; // file Upload private var file: fileReference = new FileReference (); // filter private var images_filter: FileFilter = new FileFilter ("*. jpg ,*. jpeg ,*. gif ,*. Png ","*. jpg ;*. jpeg ;*. gif ;*. png "); // upload address private var uploadURL: URLRequest; // constructor public function main () {// hide default menu var contextmenu: ContextMenu = new ContextMenu; contextmenu. hideBuiltInItems (); // this parameter is very important. It will be mentioned later that it is important to solve the problem of inconsistent sessionID uid = stage. loaderInfo. parameters. ASPSESSID; jid = stage. loaderInfo. parameters. AUTHID; // submission address uploadURL = new URLRequest ("/SwfUploadImg /? ASPSESSID = "+ uid +" & AUTHID = "+ jid); // scene Click Event btn. addEventListener (MouseEvent. CLICK, clickHandler); // specifies the event file after the image is selected. addEventListener (Event. SELECT, selectedHandler); file. addEventListener (Event. OPEN, openHandler); file. addEventListener (ProgressEvent. PROGRESS, progressHandler); file. addEventListener (IOErrorEvent. IO_ERROR, ioErrorHandler); file. addEventListener (SecurityErrorEvent. SECURITY_ERROR, securityErrorHandler); file. addEventListener (DataEvent. UPLOAD_COMPLETE_DATA, uploadCompleteDataHandler);} // click the button event private function clickHandler (evt: MouseEvent): void {// display the select image dialog box file. browse ([images_filter]);} // Event private function selectedHandler (e: Event): void {ExternalInterface. call ("Laugh_UpImg_onSelected", file. name, file. size, file. type); // starts uploading the image file. upload (uploadURL, "Filedata");} // start to upload private function openHandler (event: Event): void {ExternalInterface. call ("Laugh_UpImg_onStart");} // The private function uploadCompleteDataHandler (event: DataEvent): void {ExternalInterface. call ("Laugh_UpImg_onComplete", event. data);} // upload progress private function progressHandler (event: ProgressEvent): void {ExternalInterface. call ("Laugh_UpImg_onProgress", event. bytesLoaded, event. bytesTotal);} // upload error private function ioErrorHandler (event: IOErrorEvent): void {ExternalInterface. call ("Laugh_UpImg_onError", event. text);} // upload permission error private function securityErrorHandler (event: SecurityErrorEvent): void {ExternalInterface. call ("Laugh_UpImg_onSecurityError", event. text );}}}

Code explanation:

ExternalInterface.call
Call the external JS Code. The first parameter is the JS function name, And the next parameter is the real parameter of the function.

The function of each method can be determined based on the annotations.

stage.loaderInfo.parameters.ASPSESSID
Accept parameters sent from the page, used to submit to the. net page for permission Verification


Flash is mainly used as a tool for uploading images, and implements real-time data updates on the client and server.


Insert flash into aspnet

<Object width = "252" HEIGHT = "194"> <param name = movie VALUE = "example.swf">
<EMBED src = "example.swf" WIDTH = "252" HEIGHT = "194" NAME = "2" ALIGN = ""> </EMBED> </OBJECT>

Add this code to your plug-in, and change example.swf to the width and height of your flash path.

Like this: <embed src = "FLASH path" width = "FLASH width" height = "FLASH height"> </embed> without the <object> label, it may cause browser compatibility problems.

Flash insertion in Aspnet cannot be played

I also failed to insert FLASH into asp.net for a long time. Later, the following write is successful. You can try to modify the flash path below. I want to modify the FLASH path in two places.
<Param name = "movie" value = "rw.swf"/>
<Embed src = "rw.swf" quality = "high"
I took out the above two sentences. You can find them below and change the FLASH path and file name to your own.
<Object classid = "clsid: D27CDB6E-AE6D-11cf-96B8-444553540000" codebase = "download.macromedia.com/..sion=7,550 400" width = "" height = "">
<Param name = "movie" value = "rw.swf"/>
<Param name = "quality" value = "high"/>
<Embed src = "rw.swf" quality = "high" pluginspage = "www.macromedia.com/go/getflashplayer" type = "application/x-shockwave-flash" width = "550" height = "400"> </embed>
</Object>

I hope you will succeed. I have succeeded in both this and the upload server. There may be two reasons for your failure.
1. Your FLASH plug-in versions are different.
2. Some modifications may be made to insert FLASH into vs, And I modified it myself in VS2008.

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.