Flex Java ÉÏ´« ÏÂÔØ ×é¼þ
Flex Java ÉÏ´« ÏÂÔØ ×é¼þ ÊÕ²Ø
ÊÂÇ°×¼±¸¾ÍÊǵ½http://commons.apache.orgÏÂÔØcommon-fileupload-1.1.1.jarÒÔ¼°common-io-1.2.jarÁ½¸ö°ü¡£
ǰ̨Flex´úÂ룺
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns="*" creationComplete="init();">
<mx:Script>
<![CDATA[
import flash.net.FileReference;
import mx.controls.Alert;
import mx.events.CloseEvent;
import flash.events.*;
private var file: FileReference;
private function init(): void{
Security.allowDomain("*");
file = new FileReference();
file.addEventListener(ProgressEvent.PROGRESS, onProgress);
file.addEventListener(Event.SELECT, onSelect);
file.addEventListener(Event.COMPLETE, completeHandle);
}
private function completeHandle(event:Event):void{
Alert.show("¹§Ï²Ä㣬ÉÏ´«³É¹¦");
}
private function upload(): void{
var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.png)", "*.jpg;*.jpeg;*.png");
var allTypes:Array = new Array(imageTypes);
file.browse(allTypes);
file.browse();
}
private function onSelect(e: Event): void{
Alert.show("ÉÏ´« " + file.name + " (¹² "+Math.round(file.size)+" ×Ö½Ú)?",
"È·ÈÏÉÏ´«",
Alert.YES|Alert.NO,
null,
proceedWithUpload);
}
private function onProgress(e: ProgressEvent): void{
lbProgress.text = " ÒÑÉÏ´« " + e.bytesLoaded
+ " ×Ö½Ú£¬¹² " + e.bytesTotal + " ×Ö½Ú";
var proc: uint = e.bytesLoaded / e.bytesTotal * 100;
bar.setProgress(proc, 100);
bar.label= "µ±Ç°½ø¶È: " + " " + proc + "%";
}
private function proceedWithUpload(e: CloseEvent): void{
if (e.detail == Alert.YES){
var request: URLRequest = new URLRequest("http://localhost:8080/FileUploaded/FileUploaded");
try {
file.upload(request);
} catch (error:Error) {
trace("ÉÏ´«Ê§°Ü");
}
}
}
]]>
</mx:Script>
<mx:Canvas width="100%" height="100%" x="10" y="170" fontSize="15">
<mx:VBox width="100%" horizontalAlign="center">
<mx:Label id="lbProgress" te
Ïà¹ØÎĵµ£º
package demo;
class TA{
//Õâ¸ö³ÌÐòÒªºÃºÃÀí½â,³£Á¿²»ÊÇÊôÓÚÀàµÄ£¬ËüÔÚÄÚ´æÖÐÓÐÒ»¿éµ¥¶ÀµÄ´æ´¢ÇøÓò£¬ºÎÀàTAÎÞÈκιØϵ
// public static final int m=9;
// ¾²Ì¬±äÁ¿ÊÇÊôÓÚÀàµÄ£¬ËüµÄ´æ´¢ÇøÓòÓëÀàÏà¹Ø
public static int m=9;
static {
System.out.println("In Static m=" ......
TypeError: Error #1034: 強ÖÆÐÍ変換¤Ëʧ敗¤·¤Þ¤·¤¿¡£jp.co.nec.necst.pi.ap2web::TestEvent@1645ee79 ¤ò jp.co.nec.necst.pi.ap2web.TestEvent ¤Ë変換¤Ç¤¤Þ¤»¤ó¡£
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispat ......
¾³£ÔÚDemoÖлῴµ½ÁÐ±í£¬±í¸ñµÈ·½Ê½À´ÏÔʾÊý¾Ý¡£µ±È»ÓÐʱºòÒ²ÐèÒªÌí¼ÓÊý¾Ýµ½ÕâЩÁбí»òÕß±í¸ñÖС£Óкܶ෽ʽÌá½»£¬ÕâÀïչʾһ¸öµ¯³ö´°¿ÚµÄ·½Ê½À´Ìí¼ÓеÄÊý¾Ýµ½DataGridÖС£
Àý×Óչʾ£º
Ê×ÏÈ£¬ÎÒÃÇ¿ªÊ¼½¨ÉèÒ»¸ö»ù±¾µÄ½çÃæ½á¹¹£¬Ò»¸ö´øÓС°Notes"±êÌâµÄPanel,Ò»¸öDataGrid£¬ÒÔ¼°Ò»¸öÓÃÓÚÌá½»Êý¾ÝµÄ°´Å¥¡£
Xml´úÂë
& ......