Home > Articles > Web Development > Dreamweaver & Flash

  • Print
  • + Share This
This chapter is from the book

Saving Images to the Camera Roll

Adobe does give you access to some core iPhone specific tools. One of those is the ability to add a function that will save an image of the screen to the Camera Roll (New!). The following example saves a screen image to the Camera Roll in an iPhone App.

Save a Screen Image to Camera Roll

  • orange-circle-1.jpg Click the File menu, click New, click iPhone OS, and then click OK.
  • orange-circle-2.jpg Create a new Movie Clip on the Stage with the name snapShot.
  • orange-circle-3.jpg Add the following event Listener to:
    snapShot.addEventListener(MouseEvent.CLICK,
    myScreenShot);
    
  • orange-circle-4.jpg Add the following function that takes a screen shot of your iPhone:
    function myScreenShot (event:MouseEvent):void
    {
    if (CameraRoll.supportsAddBitmapData)
    {
          var cameraRoll:CameraRoll = new CameraRoll(); cameraRoll.addEventListener(ErrorEvent.ERROR, onCrError);
    
       cameraRoll.addEventListener(Event.COMPLETE, onCrComplete);
    
          var bitmapData:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight);
          bitmapData.draw(stage);
          cameraRoll.addBitmapData(bitmapData);
       }
       else
       {
          trace("not supported.");
       }
    }
    
  • orange-circle-5.jpg Publish and package your file into an iPhone App and test it on your iPhone.
  • + Share This
  • 🔖 Save To Your Account