2015-01-18 4 views
0

존경받는 각 버튼을 클릭하여 무비 클립을 만들 수있는 플래시 파일을 만들었습니다. 내가하고 싶은 것은, 만들어진 모든 무비 클립을 배치 한 후에 JPEG 또는 PNG 이미지 파일에 저장하고 싶습니다. 저장 버튼을 만들고 "save_page_btn"이라고 이름을 지정했습니다. AS 2.0을 사용하는 자습서를 찾으려고했지만 아무 소용이없는 것 같습니다. AS 3.0에는 기본이 없습니다. 아무도 나를이 솔루션을 찾을 수 있습니다.Screencapture 및 JPG, Actionscript 2.0에 저장

감사합니다.

답변

0

액션 2 장 : ActionScript 2의

, 당신은 내가 my answer for this question에 사용되는 PHP 스크립트와 같은 서버 측 스크립트를 사용하여 이미지를 저장해야합니다.

액션 스크립트 3 : 액션 스크립트 3

상황이 FileReference 우리의 컴퓨터에 직접 save 우리에게 파일을 수있는 기능을 제공하기 때문에 더 쉽습니다.

이미지를 jpg 또는 png 파일로 저장하려면 as3corelib 라이브러리에 포함 된 JPGEncoderPNGEncoder을 사용하면됩니다. here에서 다운로드 한 다음 파일> ActionScript 설정 ...> 라이브러리 경로에서 프로젝트에 포함시킨 다음 을 누르십시오. SWC 파일으로 이동하여 as3corelib.swc 다운로드 파일을 선택하십시오. 그럼 당신은 다음과 같이 수행 할 수 있습니다

// in my stage, I have 2 buttons : btn_save_jpg and btn_save_png, and a MovieClip : movie_clip 

import com.adobe.images.JPGEncoder; 
import com.adobe.images.PNGEncoder; 

btn_save_jpg.addEventListener(MouseEvent.CLICK, save_img); 
btn_save_png.addEventListener(MouseEvent.CLICK, save_img); 

function save_img(e:MouseEvent):void { 

    // verify which button is pressed using its name 
    var is_jpg:Boolean = (e.currentTarget.name).substr(-3, 3) == 'jpg'; 
    // you can also write it : var is_jpg:Boolean = e.currentTarget === btn_save_jpg; 

    // create our BitmapData and draw within our movie_clip MovieClip 
    var bmd_src:BitmapData = new BitmapData(movie_clip.width, movie_clip.height) 
     bmd_src.draw(movie_clip); 

    if(is_jpg){  
     // if it's the btn_save_jpg button which is pressed, so create our JPGEncoder instance 
     // for the btn_save_png button, we don't need to create an instance of PNGEncoder 
     // because PNGEncoder.encode is a static function so we can call it directly : PNGEncoder.encode() 
     var encoder:JPGEncoder = new JPGEncoder(90); 
     // 90 is the quality of our jpg, 0 is the worst and 100 is the best 
    } 

    // get encoded BitmapData as a ByteArray 
    var stream:ByteArray = is_jpg ? encoder.encode(bmd_src) : PNGEncoder.encode(bmd_src); 

    // open the save dialog to save our image 
    var file:FileReference = new FileReference(); 
     file.save(stream, 'snapshot_' + getTimer() + (is_jpg ? '.jpg' : '.png')); 

} 

을 당신이 AS3 (또는 심지어 AS2) 코드에 대한 질문이있는 경우, 코멘트 영역을 사용을 주저하지 않습니다.

희망이 도움이 될 수 있습니다.

+0

감사합니다 akmozo, 나는 두 가지 제안을 시도 할 것입니다. –