ÔËÐÐÏ¿´¿´£¬»ù±¾Ã»Ê²Ã´´óµÄÎÊÌ⣬µ±È»ÄǸö±êÇ©±È½ÏÂé·³£¬Õâ¸öû¹Øϵ£¬ÄãÒªÒ²ºÃ£¬²»ÒªÒ²ºÃ£¬×ö·¨ÓкܶࡣÕâÖ»ÊÇ»ù´ £ µ½ÁËÕâÒ»²½£¬»ù±¾ÉÏËãÊDz¶àÁË£¬ÔÚ´óÌåµÄ¿ò¼ÜÉÏ£¬¾ÍÊ£ÏÂÔ¤ÀÀÓë±£´æµÄ×ö·¨ÁË¡£ µÚÒ»²½£ºÔ¤ÀÀ
ÔËÐÐÏ¿´¿´£¬»ù±¾Ã»Ê²Ã´´óµÄÎÊÌ⣬µ±È»ÄǸö±êÇ©±È½ÏÂé·³£¬Õâ¸öû¹Øϵ£¬ÄãÒªÒ²ºÃ£¬²»ÒªÒ²ºÃ£¬×ö·¨ÓкܶࡣÕâÖ»ÊÇ»ù´¡¡£
µ½ÁËÕâÒ»²½£¬»ù±¾ÉÏËãÊDz¶àÁË£¬ÔÚ´óÌåµÄ¿ò¼ÜÉÏ£¬¾ÍÊ£ÏÂÔ¤ÀÀÓë±£´æµÄ×ö·¨ÁË¡£
µÚÒ»²½£ºÔ¤ÀÀ
ÔÚÎÒÃÇÒѾ°ÑÊÓƵ£¬TileList×é×°Íê³Éºó£¬¾ÍÐèҪʵÏÖÒ»¸ö¹¦ÄÜ£¬¾ÍÊÇÎÒÃÇÐèÒªÖØÐÂÔ¤ÀÀÏÂÒÔÇ°ÅĵÄÕÕƬ£¬ÄÇôÓÉ´ËËùÒýÉê³öÀ´µÄ¶¯×÷
±ØÈ»¾ÍÊÇÎÒÃÇÐèÒªµã»÷ÔÚTileListÀïµÄСͼ£¬ÕâÒ»²½ºÜ¼òµ¥£¬ÎÒÃÇÏÈÀ´ÍæÒ»¸öTileListµã»÷µÄС´úÂ룬ºóÃæ¾ÍÌ×һϣ¬¾ÍºÜÈÝÒ×ÁË¡£
°´ÕÕµÚ¶þ²¿·Ö£¬ÈÏʶTileList¸Õ¿ªÊ¼µÄÄǶÎС´úÂ룬еĴúÂëÈçÏ£º
- import fl.events.ListEvent;
- var i:uint;
- for(i=0;i<10;i++){
- var tempMc:Object= new Object();
- tempMc.label = “PIC“+i;
- tempMc.source = new mc();
- lists.addItem(tempMc);
-
- }
- lists.addEventListener(ListEvent.ITEM_CLICK,thumbClick);
- function thumbClick(event:ListEvent):void{
- trace(event.item.label);
- }
´ÓÉÏÃæ¼òµ¥µÄ´úÂ룬¾ÍÄÜÖªµÀÔÚTileListÀïµ¥»÷ÆäÖеÄͼ±ê£¬¸ÃÔõôȥʵÏÖ¡£
ºÃ£¬ÄÇôÖØÐÂÎÒÃǻص½ÔÀ´µÄÀý×ÓÉÏ£¬ÎÒÃÇÒѾ֪µÀTileListµã»÷ÔõôʵÏÖ£¬ÄÇôÎÒÃÇÐèÒªÔÚÎę̀ÉÏ·ÅÒ»¸ö¿ÕµÄʵÀý£¬ÓÃÓÚ¼ÓÔصã»÷ͼ
±êºó£¬´«Êä¹ýÀ´µÄ¾ßÌåÄÚÈÝ£¬ÎÒÃÇÕâÀïÖ»ÐèҪͼ£¬±ðµÄ²»ÐèÒª¡£µ±È»Äã¿ÉÒÔͬÑù´«ËÍÆäËûÐÅÏ¢¡£
ÎҵĴòËãÊÇеÄÔ¤ÀÀʵÀý·ÅÔÚXÖáΪ340£¬YÖáΪ0£¬Í¬Ê±ÔÚÎę̀ÉÏÔÙ·ÅÒ»¸öBUTTON£¬ÊµÀýÃû:down_btn£¬ÓÃÓÚ±£´æʼþµÄ´¥·¢
Ô¤ÀÀµÄ×ö·¨Ò²ÊǸú½ØͼµÄ×ö·¨Ò»Ñù£¬ÓÃBitmap,ºÍBitmapData£¬ÔÚÇ°ÃæµÄ½Ì³Ì´úÂëÉϼÌÐø¼Ó´úÂ룺
- import fl.events.ListEvent;
- var review:Sprite;
- function thumbClick(event:ListEvent):void {
- var bmd:BitmapData=new BitmapData(320,240);
- bmd.draw(event.item.source);
- var bit:Bitmap=new Bitmap(bmd);
- review = new Sprite();
- addChild(review);
- review.x = 340;
- review.addChild(bit);
- //ÓÃÓÚÏÂÔص±Ç°µÄͼƬ
- //down_btn.addEventListener(MouseEvent.CLICK,downJpg);
- }
ÕâÑù£¬Õⲿ·ÖµÄ¹¦ÄÜËãÊÇÍê³ÉÁË£¬Ò²²»ÄÑ¡£ÏÂÒ»²¿·ÖµÄÄÚÈÝÔÚÓڰѵ±Ç°µÄͼ±£´æµ½±¾µØÉÏ£¬Õâ¸öÓкܶ෽·¨£¬ÎÒ˵µÄÊÇÆäÖÐÒ»ÖÖ£¬µ«ÊÇ
´óÌåµÄ˼·¶¼ÊÇÒ»ÑùµÄ¡£ÎÒÏÈ˵ÏÂÎÒµÄ˼·¡£
»¹¼ÇµÃÎÒÒÔǰдµÄFlash¼òÒ×ÁÄÌìÊҽ̳ÌÀïµÄÈý°å¸«½Ì³ÌÂð£¿Õâ¸öÖ÷Òª½²µÄÊÇFLASHÀïµÄÊý¾Ý´«Êäµ½Íⲿ·þÎñÆ÷µÄ£¬ÕâÀïÎÒÒª±£´æͼƬ£¬
ÄÇôҲÊǰѵ±Ç°µÄͼƬÊý¾Ý´«Êä³öÈ¥£¬ÄÇôÎÒÃǾÍÐèÒªCORDLIBÀïµÄÒ»¸öÀà: JPGEncoderÀ࣬°Ñµ±Ç°µÄͼƬÊý¾Ýת»¯³ÉByteArray£¬´«Êä³öÈ¥£¬
Èç¹ûÄãÏñÎÒÓõÄÊÇPHPµÄ»°£¬¾Í¿ÉÒÔÓÃPHP°ÑByteArrayдµ½±¾µØÉÏ£¬±ä»ØÔÀ´µÄͼƬ¡£
µÚ¶þ²½£º±£´æ
Ê×ÏÈÎÒÃÇҪȥhttp://code.google.com/p/as3corelib/°ÑJPGEncoderÀàÏÂÏÂÀ´¡£
È»ºóÏÂÒ»²½¾ÍÊǼÌÐøÍê³Édown_btn°´Å¥´¥·¢µÄÏÂÔØʼþ¹¹Ô캯Êý£ºdownJpg
- import flash.utils.ByteArray;
- import com.adobe.encoding.JPEGEncoder;
- function downJpg(event:MouseEvent):void {
- //?name=@@@@@@¾ÍÊÇÉèÖÃÏÂÔØÏÂÀ´µÄͼƬÃû×Ö£¬Õâ¸ö¿ÉÒÔ¸ù¾ÝÄã×Ô¼ºÏëÒªµÄÀ´Ð޸ġ£
- var url:String=“http://localhost/downjpg.php?name=testJpg.jpg“;
-
- var bmd:BitmapData = new BitmapData(320,240);
- bmd.draw(review);
- //ÏÂÔؽØͼÖÊÁ¿ÉèÖÃ
- var jpgEncoder:JPEGEncoder=new JPEGEncoder(100);
- var myByteArray:ByteArray=jpgEncoder.encode(bmd);
-
- //·¢ËÍÊý¾Ýµ½PHP·þÎñÆ÷¶Ë£¬È»ºó×Ô¶¯µ¯³ö£¬ÎÒÏÂÃæ»áÌṩһ¸öPHPÎļþ£¬¹©Äã²âÊÔ£¬·´Õý
- //¸ù¾ÝÎÒÒÔÇ°µÄ×öµÄºÜ¶à¶«Î÷À´¿´£¬·½·¨ÓÐN¶à¡£ÕâÊÇÆäÖÐÖ®Ò»
- var header:URLRequestHeader = new URLRequestHeader (“Content-type“, “application/octet-stream“);
- var request:URLRequest=new URLRequest(url);
- request.requestHeaders.push(header);
- request.method=URLRequestMethod.POST;
- request.data=myByteArray;
-
- var loader:URLLoader = new URLLoader();
- navigateToURL(request, “_blank“);
- }
PHP¶ËµÄ´úÂ룺
- if ( isset ( $GLOBALS[“HTTP_RAW_POST_DATA“] )) {
- $im = $GLOBALS[“HTTP_RAW_POST_DATA“];
- header(’Content-Type: image/jpeg’);
- header(“Content-Disposition: attachment; filename=“.$_GET[’name’]);
- echo $im;
- } else echo ’An error occured.’;
- ?>