FlexÖÐÎļþµÄÉÏ´«ÏÂÔØ
¹Ø¼ü´Ê£ºÎļþÉÏ´«£¬ÎļþÏÂÔØ£¬FileReference£¬FileReferenceList£¬FileFilter
ÔÚÏîÄ¿¿ª·¢¹ý³ÌÖУ¬¾³£»áÓöµ½ÎļþÉÏ´«ÏÂÔصÄÎÊÌâ¡£µ«ÔÚflexÖÐÓÉÓÚ°²È«É³ÏäµÄÔÒò£¬flex³ÌÐò²»ÄÜÖ±½Ó·ÃÎʱ¾µØÎļþ¡£µ«ÊÇflex SDKÖÐÌṩÁËFileReferenceºÍFileReferenceListÁ½¸öÀ࣬¿ÉÒÔͨ¹ýÕâÁ½¸öÀàÀ´ÊµÏÖ£¬ÕâÁ½¸öÀàλÓÚflash.net°üÖС£
Ò»¡¢ ÎļþÉÏ´«
ÉÏ´«Îļþflex¶Ë´¦Àí£º
1¡¢ÉÏ´«ÎļþµÚÒ»²½——´ò¿ªÎļþ¡£
Ê×ÏÈÐèÒª´´½¨Ò»¸öFileReference¶ÔÏó£º
private var myFileReference:FileReference = new FileReference();
ÔÚFileReferenceÖÐÓÐÒ»¸öbrowse()º¯Êý£¬Õâ¸öº¯ÊýµÄ×÷ÓþÍÊÇ´ò¿ªÒ»¸öwindowsÎļþÑ¡Ôñ¿ò£¬¿ÉÒÔÑ¡ÔñÐèÒªÉÏ´«µÄÎļþ¡£ÔÚ´ò¿ªµÄÎļþÑ¡Ôñ¿òÖпÉÒÔÖ¸¶¨Ñ¡ÔñÎļþµÄÀàÐÍ£¬ÕâÊÇͨ¹ýFileFilterÀ´ÊµÏֵġ£´´½¨Ò»¸öFileFilter¶ÔÏó£¬×÷Ϊbrowseº¯ÊýµÄ²ÎÊý£¬ÕâÑù¾Í¿ÉÒÔÖ¸¶¨Ñ¡ÔñÎļþµÄÀàÐÍÁË£º
var imagesFilter:FileFilter = new FileFilter("Images(*.jpg,*.gif,*.png)", "*.jpg;*.gif;*.png");
myFileReference.browse([imagesFilter]);
2¡¢ÉÏ´«ÎļþµÚ¶þ²½——ÉÏ´«Îļþ
ÎļþÑ¡ÔñÁËÖ®ºó»á´¥·¢Event.SELECTʼþ£¬ËùÒÔÐèÒªÔÚmyFileReference¶ÔÏóÉÏ×¢²áSELECTʼþµÄ¼àÌý£º
myFileReference.addEventListener(Event.SELECT, onSelect);
onSelectÊÇÒ»¸ö¼àÌýº¯Êý£¬ÔÚÕâ¸öº¯ÊýÖпÉÒԵõ½Ñ¡ÔñµÄÎļþµÄÃû×Ö¡£ÓÉÓÚ°²È«É³ÏäµÄÔÒò£¬Ö»Äܵõ½Ñ¡ÔñµÄÎļþÃû£¬²»Äܵõ½ÍêÕûµÄÎļþ·¾¶¡£Ñ¡ÔñÁËÐèÒªÉÏ´«µÄÎļþºó£¬ÐèÒªµ÷ÓÃupload()º¯ÊýÉÏ´«Ñ¡ÔñµÄÎļþ£º
myFileReference.upload(uploadURL,myFileReference.name);
uploadµÄ²ÎÊýuploadURLÊÇÒ»¸öURLRequest¶ÔÏó£¬Õâ¸ö¶ÔÏóÖ¸¶¨ÁËÉÏ´«ÎļþÓõÄURL£¬myFileReference.name¾ÍÊÇÑ¡ÔñµÄÎļþµÄÎļþÃû¡£
3¡¢ÉÏ´«ÎļþµÚÈý²½——ÉÏ´«½ø¶È
Ò»°ãÇé¿öÏ£¬ÔÚÉÏ´«ÎļþµÄ¹ý³ÌÖÐÐèÒªÏÔʾһ¸ö±íʾÉÏ´«½ø¶ÈµÄ½ø¶ÈÌõ£¬ÕâÑù¿ÉÒÔÓÐÒ»¸öºÜºÃµÄÓû§ÌåÑé¡£ÒªÏëÏÔʾÉÏ´«½ø¶È£¬¿ÉÒÔÓÐÁ½ÖÖ·½Ê½¡£µÚÒ»ÖÖ¾ÍÊǼàÌýFileReference¶ÔÏóµÄprocessʼþ£¬ÔÚprocessʼþµÄ¼àÌýº¯ÊýÖпÉÒԵõ½ÉÏ´«µÄ½ø¶È£¬È»ºó¿ÉÒÔÉèÖýø¶ÈÌõµÄ½ø¶È¡£µÚ¶þÖÖ·½Ê½¾ÍÊÇ°ÑFileReference¶ÔÏóÓë½ø¶ÈÌõ¶ÔÏó½øÐа󶨣¬½ø¶ÈÌõ»á×Ô¶¯¼àÌýFileReference¶ÔÏóµÄprocessʼþ£¬À´ÏÔʾÉÏ´«½ø¶È¡£
4¡¢ÉÏ´«ÎļþµÚËIJ½——ÉÏ´«½áÊø
ÓеÄʱºòÐèÒªÔÚÎļþÉÏ´«½áÊøºó¸øÓû§Ò»¸öÌáʾ£¬¸æËßÓû§ÎļþÒѾÉÏ´«½áÊøÁË¡£Õâ¾Í±ØÐëµÃ¶ÔFileReference¶ÔÏóµÄCOMPLETEʼþ½øÐ
Ïà¹ØÎĵµ£º
Flex Óë JavaScript ½»»¥£¬Ö÷ÒªÒÀ¿¿FlexµÄExternalInterface£¬ÆäÌṩÁËaddCallBackºÍcall·½·¨.
ÏÂÃæµÄÀý×Ó½«ÑÝʾFlexµ÷ÓÃjavascript£¬ºÍjavascriptµ÷ÓÃFlex¡£
js ´úÂë
-------------------------------------------------------------------------------------------------------------
function hello(param) {
......
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12" creationComplete="init()">
<mx:Script>
<!--[CDATA[
import mx.utils.*;
import flash.net.*;
......
1.flex²ú³öÎïµÄÐÎʽÓÐÁ½ÖÖ flashÎļþ »òÕßairÎļþ¡£
1).flashÓÃflash player²¥·Å
2).airÎļþÐèÒªÓÃflexµÄruntimeÔËÐУ¬ÀàËÆjavaµÄjre ºÍ.netµÄ.net runtime
2.ʹÓÃflex builder¿ÉÒÔ¿ÉÊÓ»¯¿ª·¢£¬ÓÐjava»òÕß.net»ù´¡£¬»òÕßjavacript»ù´¡+ÃæÏò¶ÔÏó»ù´¡£¬ÈëÃźÜÈÝÒס£
3.ÌṩÁËһЩÀà¿â£¬¿ÉÒÔʹÓá£
4.Í ......
ÔÚÓÃflex×öWebÓ¦ÓÃʱΪÁËÀ©Õ¹Ó¦ÓóÌÐò¹¦ÄÜ£¬ÊƱػá¸ü¶àµÄͬä¯ÀÀÆ÷½øÐн»»¥£¬ÕâÑù¾Í»áÓõ½ÏÂÃæ½éÉܵÄ֪ʶ
1¡¢ÔÚFlexÖÐʵÏÖURL Ìøת(ʹÓÃflash.net.navigateToURL()·½·¨È磺)
/*
* param1: ÒªÌøתµÄURL
* param2: Ìøת·½Ê½ _blank /_self
*/
navigateToURL(new URLR ......
1£º¼ÙÈçÄãÒªÉÖÆÒ»¸öÀàA
public class A
{
¡¡¡¡public var vo:B
}
ÄãÊ×ÏÈÒª×öµÄÊÇ×¢²áÀ࣬ÀýÈ磺
public static function registerClass():void
{
¡¡¡¡//°Ñ×ÓÀà×¢²á
PackUtil.registerClass(B);
}
//½ÓÏÂÀ´¾ÍÊÇ¿Ë¡£º
¡¡¡¡var cloneA:A=clone(A);
cloneA¾ÍÊÇÎÒ ......