A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Save Images from Flash Movie

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Posts
    1

    Save Images from Flash Movie

    I am looking to save images, frames, screenshots, etc. from flash movie to image.
    Flashplayer 10 can do it.....

    Need help converting script for swishmax.
    Believe I will have to edit the html output to state flashplayer10 to load finished movie.

    Here is the script..

    With the release of Flash Player 10, we can now save files locally from within the player itself.
    EXPLANATION

    Provided it is a "user initiated" save (in result to a user event, such as clicking a button) you can save an image snapshot locally. As long as your code is targetting Flash Player 10 you can use the following code (for saving a PNG - you can save anything you want):
    var fileRef:FileReference = new FileReference();
    fileRef.save(byteArray, "filename.png");

    Here's a simple example:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
    <mx:Script>
    <![CDATA[
    import mx.graphics.codec.PNGEncoder;
    private var cam:Camera;
    private function init():void
    {
    cam = Camera.getCamera();
    vid.attachCamera(cam);
    }

    private function takeIt():void
    {
    var bd:BitmapData = new BitmapData(vid.width,vid.height);
    bd.draw(vid);

    var png:PNGEncoder = new PNGEncoder();
    var ba:ByteArray = png.encode(bd);

    var fr:FileReference = new FileReference();
    fr.save(ba, "mySnapshot.png");
    }
    ]]>
    </mx:Script>
    <mx:VideoDisplay id="vid" width="320" height="240" x="10" y="10" />
    <mx:Button label="Take a Picture" click="takeIt()" x="340" y="20" />
    </mx:Application>

    source: http://www.adobe.com/cfusion/communi...2&postId=14426

  2. #2
    Flashkit historian Frets's Avatar
    Join Date
    Oct 2000
    Location
    flashkit
    Posts
    8,797
    the player could always do that. use the print function.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center