PNGEncoder

Dear All,
Hopefully someone will be able to shed some light on an issue
I'm having. I'm fairly new to both Flex 2 and AS3 - but getting
there.
I have a BitmapData object that contains a snapshot taken
from a webcam - this all works fine. I now want to pass this data
out to a server as a PNG and let the server save it as a file.
I'm trying to use the
PNGEncoder
class from labs.adobe.com and I'm passing it my BitmapData
object for encoding.
All I seem to get back from this are the PNG headers. Any
thoughts on what I might be doing wrong?
Thanks guys,
Dave.

Dear All,
I'm still really struggling with this so any help would be
great.
I'n now using Flex Builder 3 (beta) with the inbuilt support
for the PNGEncoder class but no matter what I send it in the encode
method, all I get back are PNG headers.
Any thoughts?
Dave.

Similar Messages

  • Is there any way to save an image from a nested movieclip as a .png using PNGEncoder

    Hello all,
    I am new to AIR and AS3 and I am developing a small AIR desktop application in Flash CS5 that saves a user generated image locally to their computer. 
    The image is generated from a series of user choices based on .png files that are loaded dynamically into a series of nested movieclips via XML.  The final image is constructed by a series of these "user choices".
    Sourcing alot of code examples from here and there, I have managed to build a "working" example of the application.  I am able to "draw" the parent movieclip to which all the other dynamic movieclips reside and can then encode it using PNGEncoder.  The problem is that the images loaded dynamically into the nested movieclips show as blank in the final .png generated by the user.
    Is there a way to "draw" and encode these nested movieclips or do I need to find another way?  I can provide my clumsy code if required but would like to know if this concept is viable before moving any further.....
    Thanks in advance....

    Thanks for the files.......
    Yeah I'm doing it in Flash but importing the images via an xml document.  The problem isn't in being able to view the eyes (based on the selection of the user) its when I go to save the resulting image as a .png.  When I open up the saved .png the eyes are blank even though they are visible in the swf
    Even when the user clicks on the option to copy the image to the clipboard, it works as intended.
    My only guess is there is an issue with the way my xml is loading (but this appears to work fine) or when the file is converted and saved.....
    As I said I'm still learning but surely there must be a simple answer to this....
    I have included the xml code I am using and also the save code to see if anyone spots an issue..... (I hope I copied it all)
    // XML
    import flash.net.URLRequest;
    import flash.net.URLLoader;
    var xmlRequest:URLRequest = new URLRequest("imageData.xml");
    var xmlLoader:URLLoader = new URLLoader(xmlRequest);
    var imgData:XML;
    var imageLoader:Loader;
    var imgNum:Number = 0;
    var numberOfChildren:Number;
    function packaged():void
    rawImage = imgData.image[imgNum].imgURL;
    numberOfChildren = imgData.*.length();
    imageLoader = new Loader  ;
    imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedImage);
    imageLoader.load(new URLRequest(rawImage));
    faceBG_mc.Eyes.addChild(imageLoader);
    function loadedImage(event:Event):void
    imageLoader.x = -186;
    imageLoader.y = -94;
    imageLoader.width = 373;
    imageLoader.height = 186;
    //  Clipboard
    btn_Copy.addEventListener(MouseEvent.CLICK, onCopyClick);
    function onCopyClick(event:MouseEvent):void
    var bd:BitmapData = renderBitmapData();
    Clipboard.generalClipboard.setData(ClipboardFormats.BITMAP_FORMAT, bd);
    function renderBitmapData():BitmapData
    var bd:BitmapData = new BitmapData(faceBG_mc.width,faceBG_mc.height);
    bd.draw(faceBG_mc);
    return bd;
    // Save faceBG_mc as .png 
    var fileRef:FileReference = new FileReference();
    var myBitmapData:BitmapData = new BitmapData (faceBG_mc.width,faceBG_mc.height, true, 0);
    myBitmapData.draw(faceBG_mc);
    var myPNG:ByteArray = PNGEncoder.encode(myBitmapData);
    function onSaveClickPNG(e:Event)
    fileRef.save(myPNG, "myPNG.png");
    So my problem is....
    The final image is copied to the clipboard with the eyes visible - yes
    The eyes appear in the image in the swf as intended - yes
    When the image is saved as a .png and is meant to include the eyes, they are blank (see picture above)
    I hope this helps.....
    Thanks in advance

  • Can't compile the pngencoder.swc form the sample/libpng

    Hi,
    I tried without success to compile the png lib port form the Alchemy's sample. Is it possible to find this file pngencoder.swc already compiled?
    Thanks
    Julien Félix

    I found it, thank you fT!

  • ImageSnapshot and PNGEncoder in Flash

    As usual I've come across something easy to do in Flex but not in Flash. Flex
    has ImageSnapshot and PNGEncoder to get a .png out of a display object.
    I was wondering if there were any way to do this in flash without using a 3rd party API
    as I can't distribute a license with my app.
    I'm using Flash CS5. I wish there was as much support for Flash as there is for Flex.
    I've had to write my own tree component, if I'd have used Flex I could have just used the
    Flex tree component. I'm hoping I don't have to write my own display object to png class
    myself.
    Cheers,
    Alex.

    The AS3 core lib has a jpeg encoder, png encoder and some other nice utility classes.
    http://github.com/mikechambers/as3corelib
    Been around for years...

  • PNGEncoder lose transparent quality

    I've got problem with transparent using PNGEncoder class. When I encode BitmapData to png and use it as source of my Image, it looks terrible. I attach example. There are two images - first colorful and above him white with alpha gradient.
    I've used some other libraries like AsPngEncoder, but it didn't help. It's code I use:
    var bd:BitmapData = new BitmapData(container.width, container.height, true, 0xffffff);
    bd.draw(container);
    var pngenc:PNGEncoder = new PNGEncoder();
    var pngByteArray:ByteArray = pngenc.encode(bd);
    container.source = pngByteArray;
    var fl:File = File.applicationStorageDirectory.resolvePath("./images/file.png");
    var fs:FileStream = new FileStream();
    fs.open(fl, FileMode.WRITE);
    fs.writeBytes(pngByteArray);
    fs.close();
    I've tried also new Air 3.3 feature:
    var pngByteArray:ByteArray = new ByteArray();
    bd.encode(new Rectangle(0,0,bd.width,bd.height), new flash.display.PNGEncoderOptions(), pngByteArray);
    but it doesn't help. When I save the same image 3-4 times it looks terrible.

    I can send you a free copy of my SWFresolutionChanger script if you like. I don´t know does it work for that purpose, but if you wanna give it a shot, send me an email: petteri.paananen[at]***prepress.fi  (change [at] to @ and remove stars)
    With the script you can change your default SWF export resolution... I´m not sure is it working if you use losless....

  • Image select, resize and locally store (flex3 air example)

    Hi there,
    After a few days of struggling with images, resize functions
    and file dialog boxes I created a nice example application that
    shows how you can select an image, resize it and save the resized
    image in the application storing directory.
    I hope you can profit from it.
    Greets, jacob
    example code for flex 3 air.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:Script>
    <![CDATA[
    import mx.graphics.codec.PNGEncoder;
    public var imageFile:File;
    public var fileresultimage:Object;
    public var fileresultlabel:Object;
    // File.applicationStorageDirectory gets you to the local
    storage dir
    //On Windows, this is the "projectname" directory
    //(for example, C:\Documents and Settings\application
    data\projectname).
    // On Mac OS, it is /Users/userName/Documents.
    public var docsDir:File = File.applicationStorageDirectory;
    public function
    imageFileDialog(image:Object,label:Object):void
    fileresultimage=image;
    fileresultlabel=label;
    var imagesFilter:FileFilter =
    new FileFilter("Foto (*.jpg, *.gif, *.png)",
    "*.jpg;*.gif;*.png");
    if(imageFile==null)
    imageFile = new File();
    imageFile.addEventListener(Event.SELECT, imageSelected);
    imageFile.browseForOpen("Select an Image",[imagesFilter]);
    // if there is a file selected
    public function imageSelected(event:Event):void
    var newFile:File = event.target as File;
    //if there is a file object on the screen
    if(fileresultimage!=null)
    fileresultimage.source=imageFile.url;
    //if there is a label object on the screen
    if(fileresultlabel!=null)
    fileresultlabel.text=imageFile.url;
    if (newFile.exists==true)
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    handleImageComplete);
    loader.load(new URLRequest(imageFile.url));
    // when load of the selected image is complete we save a
    smaller version of it.
    public function handleImageComplete(event:Event):void
    var loader:Loader = Loader(event.target.loader);
    // width and heigt of selected image
    var originalimgwidth:Number=event.target.width;
    var originalimgheight:Number=event.target.height;
    //put original image into bitmapdata
    var bitmapje:BitmapData;
    bitmapje=new BitmapData(originalimgwidth, originalimgheight,
    true, 0x00000000);
    //bitmapje.draw(loaderInfo.loader.content,null,null,null,null,true);//null
    object reference
    bitmapje.draw(loader.content,null,null,null,null,true);
    // call the resize function and give the original
    image,maxx,and maxy with it.
    var thumb:BitmapData=resizeimage(bitmapje,150,150);
    var newimagefile:File=new File();
    // T = Thumbnail
    // 1 = next id in the db
    // for now we use a random number
    var random:Number= Math.random();
    random = Math.ceil(random*100);// to get a positive number
    var filenameForSave:String="T"+random; //new filename;
    newimagefile=docsDir.resolvePath("Thumbs/" + filenameForSave
    + ".png"); //image path
    var stream:FileStream = new FileStream; // create new
    filestream
    stream.open(newimagefile, FileMode.WRITE); // open
    filestream
    var data:ByteArray = encodeToPng(thumb); // convert
    bitmapdata to a png bytearry
    stream.writeBytes(data, 0, data.length); // writing the
    image
    stream.close();
    // show the saved thumb
    savedthumb.source=newimagefile.nativePath;
    bitmapje=null;
    thumb=null;
    // resize function
    private function
    resizeimage(image:BitmapData,maxx:Number,maxy:Number):BitmapData
    var bmp:BitmapData =image;
    var true_width:Number = bmp.width;
    var true_height:Number = bmp.height;
    var resize:Boolean=false;
    if (true_width>maxx) resize=true;
    if (true_height>maxy) resize=true;
    if (resize==true)
    var width:Number=maxx;
    var height:Number = (width / true_width) * true_height;
    true_width=width;
    true_height=height;
    if (true_height>maxy)
    height=maxy;
    width = (height/true_height)*true_width;
    else
    width=true_width;
    height=true_height;
    else
    width=true_width;
    height=true_height;
    //new calculated width and heigt relative to the given maxx
    and maxy.
    width=Math.ceil(width);
    height=Math.ceil(height);
    //create a new image object with the calculated widht and
    height for the smaller image
    var mysmallimage:Image=new Image();
    mysmallimage.width=width;
    mysmallimage.height=height;
    //new matrix for smaller image
    var m : Matrix = new Matrix() ;
    //scale the matrix to the correct sizes.
    m.scale( mysmallimage.width / bmp.width, mysmallimage.height
    / bmp.height ) ;
    //draw the image into the image object
    mysmallimage.graphics.beginBitmapFill( bmp, m, false, true )
    mysmallimage.graphics.drawRect( 0, 0, mysmallimage.width,
    mysmallimage.height ) ;
    mysmallimage.graphics.endFill();
    //put the smaller image into bitmapdata so it can be
    returned.
    var littlebitmapdata:BitmapData=new
    BitmapData(mysmallimage.width,mysmallimage.height,true,0x00000000);
    littlebitmapdata.draw(mysmallimage);
    // set the temporary small image to null so the GC can
    remove it from the memmory.
    mysmallimage=null;
    bmp=null;
    //returning the small image.
    return littlebitmapdata;
    // encoder to png
    private function encodeToPng(bmd:BitmapData):ByteArray
    var png:PNGEncoder= new PNGEncoder();
    return png.encode(bmd);
    ]]>
    </mx:Script>
    <!--<mx:Image id="tempimage" x="404" y="36"
    complete="temploadcomplete()"/>-->
    <mx:Image id="myimg" x="10" y="55" width="314"
    height="227" verticalAlign="middle" horizontalAlign="center"/>
    <mx:TextInput id="imageurl" x="53" y="303" width="160"
    maxWidth="160"/>
    <mx:Button x="221" y="303" label="Bladeren"
    click="imageFileDialog(myimg,imageurl)"/>
    <mx:Image x="346" y="55" id="savedthumb"/>
    <mx:Text x="23" y="0" text="Original image with limit
    width and height to show it on the screen." height="47"
    width="177"/>
    <mx:Text x="346" y="0" text="Local stored thumbnail"/>
    </mx:WindowedApplication>
    To bad the attach code button still isn't fixed :(

    Hi there,
    Will you be able to provide the backend script for saving the
    file data?Will you be able to provide the backend script for saving
    the file data?
    This example is created for a desktop application. Saving the
    file is included in this example, it saves in the application
    storage directory.
    // File.applicationStorageDirectory gets you to the local
    storage dir
    //On Windows, this is the "projectname" directory
    //(for example, C:\Documents and Settings\application
    data\projectname).
    // On Mac OS, it is /Users/userName/Documents.
    If you attempt to use certain functionality in a website, you
    need other functionality for storing the image on the server. There
    are lots of examples on that one.. Perhaps i need it in the future.
    If i do i will post an example on the forum.
    Also, may I post your link to other forums, so that others may
    benefit?
    Sure you may post the example on other websites and forums.
    I found it difficult to find nice examples, so the more the
    better ;)
    Just put underneath the example something like:
    Created By: Jacob Hingst From Holland
    No copyright attached, so free for your use.

  • URGENT! Alive PDF - export PDF file ("my computer" prompt to save the file, not create in browser)

    Hi - I'm having issues with my code and I'm not an ActionScript coder by any means. I'm using Flash Builder 4. I've been able to figure out how to export to PNG and to XLS but PDF is really killing me.
    Below is my code and it's not causing errors when I do the release build but the my button doesn't work to export to PDF.  I'm trying to create a PNG using the PNGEncoder and then push that out to PDF (when the PDF button is selected). I used some sample code and I've commented out parts that I didn't want to use or didn't seem to apply to my application. Unfortunately, I have a deadline of May 3rd on this and there is no one else in the office here to help me... hope someone out there can.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="650" width="850">
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                import flash.events.Event;
                import mx.events.DropdownEvent;
                import mx.events.*;
                import mx.graphics.codec.PNGEncoder;
                import org.alivepdf.display.*;
                import org.alivepdf.images.ColorSpace;
                import org.alivepdf.fonts.*;
                import org.alivepdf.layout.*;
                import org.alivepdf.pdf.*;
                import org.alivepdf.saving.*;
                import mx.controls.Alert;
                //PDF Export information
                protected var pdf:PDF;
                protected function savePDF(event:MouseEvent): void {
                    pdf = new PDF(Orientation.LANDSCAPE, Unit.MM, Size.LETTER);
                    pdf.setDisplayMode(Display.FULL_WIDTH);
                    pdf.addPage();
                    var bd:BitmapData = new BitmapData(cChart.width,cChart.height);
                    bd.draw(cChart);
                    var png:PNGEncoder = new PNGEncoder();
                    var ba:ByteArray = png.encode(bd);
                    //try {
                    pdf.addImageStream(ba, ColorSpace.DEVICE_RGB, new Resize ( Mode.FIT_TO_PAGE, Position.CENTERED ), 10, 10, 800, 800, 0, 1, "Normal", null);
                    //} catch (e:Error) {
                    //    trace("Error occurred!");
                    //    Alert.show(e,"");
                    //myPDF.addImageStream(new jpgBytes() as ByteArray, ColorSpace.DEVICE_RGB, null, 0, 0, 500, 500, 0, 1, "Normal", null);
                    //imageBytes:ByteArray, colorSpace:String, resizeMode:Resize=null, x:Number=0, y:Number=0, width:Number=0, height:Number=0, rotation:Number=0, alpha:Number=1, blendMode:String="Normal", link:ILink=null):
                    //pdf.setFont(FontFamily.ARIAL, Style.NORMAL, 12);
                    //pdf.addText("Grafico de Rata de Fallas", 100, 40); // title
                    //pdf.addImage(imprimirRata, 50, 50, 200, 150); // captured canvas with charts
                    //      pdf.addImage(leyendaImprimir, 50, 120, 20,20); // captured leyend of charts
                    //pdf.addText("RTP Software. Modulo de Score Card.", 10, 200); // header of the document
                    //pdf.addText("Creado: " + new Date(), 180, 200); // Add the created date as a leyend or footer on document
                    var fr:FileReference = new FileReference();
                    fr.save(pdf.save(Method.LOCAL), "nep_piefy11.pdf");
                    /*var fs:FileStream = new FileStream();
                    var file: File = File.desktopDirectory.resolvePath("nep_piefy11.pdf"); // Name of the file
                    fs.open(file, FileMode.WRITE);
                    fs.writeBytes(pdf.save(Method.LOCAL));
                    fs.close();*/
                    //Alert.show("El reporte ha sido generado", "Informacion"); // Confirmation message as a pop-up
                //Pie Chart Creation information
                [Bindable]
                public var ds:ArrayCollection = sel;
                private function changeEvt(event:Event):void {
                    if(filterCombo.selectedItem == 'Select NEP') {ds = sel;}
                    if(filterCombo.selectedItem == 'Albemarle-Pamlico Estuary Program') {ds = nep1;}
                    if(filterCombo.selectedItem == 'Barataria-Terrebonne Estuary Program') {ds = nep2;}
                    if(filterCombo.selectedItem == 'Barnegat Bay Estuary Program') {ds = nep3;}
                    if(filterCombo.selectedItem == 'Buzzards Bay National Estuary Program') {ds = nep4;}
                    if(filterCombo.selectedItem == 'Casco Bay Estuary Partnership') {ds = nep5;}
                    if(filterCombo.selectedItem == 'Charlotte Harbor Estuary Program') {ds = nep6;}
                    if(filterCombo.selectedItem == 'Coastal Bend Bays and Estuaries Program') {ds = nep7;}
                    if(filterCombo.selectedItem == 'Delaware Estuary Program') {ds = nep8;}
                    if(filterCombo.selectedItem == 'Delaware Inland Bays Estuary Program') {ds = nep9;}
                    if(filterCombo.selectedItem == 'Galveston Bay Estuary Program') {ds = nep10;}
                    if(filterCombo.selectedItem == 'Indian River Lagoon NEP') {ds = nep11;}
                    if(filterCombo.selectedItem == 'Long Island Sound Study') {ds = nep12;}
                    if(filterCombo.selectedItem == 'Lower Columbia River Estuary') {ds = nep13;}
                    if(filterCombo.selectedItem == 'Maryland Coastal Bays Program') {ds = nep14;}
                    if(filterCombo.selectedItem == 'Massachusetts Bays NEP') {ds = nep15;}
                    if(filterCombo.selectedItem == 'Mobile Bay Estuary Program') {ds = nep16;}
                    if(filterCombo.selectedItem == 'Morro Bay Estuary Program') {ds = nep17;}
                    if(filterCombo.selectedItem == 'Narragansett Bay Estuary Program') {ds = nep18;}
                    if(filterCombo.selectedItem == 'New York-New Jersey Harbor Estuary Program') {ds = nep19;}
                    if(filterCombo.selectedItem == 'Peconic Estuary Program') {ds = nep20;}
                    if(filterCombo.selectedItem == 'Piscataqua Region Estuaries Partnership') {ds = nep21;}
                    if(filterCombo.selectedItem == 'Puget Sound Partnership') {ds = nep22;}
                    if(filterCombo.selectedItem == 'San Francisco Estuary Project') {ds = nep23;}
                    if(filterCombo.selectedItem == 'San Juan Bay NEP') {ds = nep24;}
                    if(filterCombo.selectedItem == 'Santa Monica Bay Restoration Project') {ds = nep25;}
                    if(filterCombo.selectedItem == 'Sarasota Bay Estuary Program') {ds = nep26;}
                    if(filterCombo.selectedItem == 'Tampa Bay Estuary Program') {ds = nep27;}
                    if(filterCombo.selectedItem == 'Tillamook Estuaries Partnership') {ds = nep28;}
                [Bindable]
                private var sel:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0.5},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 0} ]);
                [Bindable]
                private var nep1:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 778.44},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0.45},
                    { habtype: "Estuarine Shoreline", Acres: 1276.30},
                    { habtype: "Instream", Acres: 1.0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0.75},
                    { habtype: "Upland", Acres: 779.74},
                    { habtype: "Wetland", Acres: 3268.31} ]);
                [Bindable]
                private var nep2:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 7.25},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 1185} ]);
                [Bindable]
                private var nep3:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 35.21},
                    { habtype: "Upland", Acres: 852.57},
                    { habtype: "Wetland", Acres: 197.82} ]);
                [Bindable]
                private var nep4:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 751.82},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 321.82},
                    { habtype: "Wetland", Acres: 157.35} ]);
                [Bindable]
                private var nep5:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 217},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 324.5},
                    { habtype: "Wetland", Acres: 0} ]);
                [Bindable]
                private var nep6:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 1268},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 50},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 61},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 809},
                    { habtype: "Wetland", Acres: 1690} ]);
                [Bindable]
                private var nep7:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 726} ]);
                [Bindable]
                private var nep8:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0.28},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 82},
                    { habtype: "Estuarine Shoreline", Acres: 0.14},
                    { habtype: "Instream", Acres: 2.3},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 643},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 501.9},
                    { habtype: "Upland", Acres: 148.71},
                    { habtype: "Wetland", Acres: 2586.02} ]);
                [Bindable]
                private var nep9:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 26.21},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 37},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 27},
                    { habtype: "Wetland", Acres: 646} ]);
                [Bindable]
                private var nep10:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 2868},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 407.06} ]);
                [Bindable]
                private var nep11:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 5},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 3},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 43},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 12910.5},
                    { habtype: "Wetland", Acres: 5026} ]);
                [Bindable]
                private var nep12:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 67},
                    { habtype: "Beach/Dune", Acres: 21.95},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 120.72},
                    { habtype: "Wetland", Acres: 151.08} ]);
                [Bindable]
                private var nep13:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 12},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 194},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 200} ]);
                [Bindable]
                private var nep14:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 58},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 153},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 494.3},
                    { habtype: "Wetland", Acres: 0} ]);
                [Bindable]
                private var nep15:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 1313},
                    { habtype: "Estuarine Shoreline", Acres: 8},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 543.8} ]);
                [Bindable]
                private var nep16:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 40},
                    { habtype: "Estuarine Shoreline", Acres: 6.5},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 195},
                    { habtype: "Wetland", Acres: 85} ]);
                [Bindable]
                private var nep17:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 1109.9},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 1.14},
                    { habtype: "Estuarine Shoreline", Acres: 0.28},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0.71},
                    { habtype: "Wetland", Acres: 0} ]);
                [Bindable]
                private var nep18:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 1099},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 0} ]);
                [Bindable]
                private var nep19:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 101.3} ]);
                [Bindable]
                private var nep20:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 98.72},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 17.99},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 106.13},
                    { habtype: "Wetland", Acres: 12.97} ]);
                [Bindable]
                private var nep21:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 9},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 3},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 2},
                    { habtype: "Upland", Acres: 1451},
                    { habtype: "Wetland", Acres: 27} ]);
                [Bindable]
                private var nep22:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 26},
                    { habtype: "Beach/Dune", Acres: 1.65},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 240.39},
                    { habtype: "Estuarine Shoreline", Acres: 314.97},
                    { habtype: "Instream", Acres: 505.87},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 1450.47},
                    { habtype: "Upland", Acres: 1176.7},
                    { habtype: "Wetland", Acres: 850.58} ]);
                [Bindable]
                private var nep23:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 43.05},
                    { habtype: "Upland", Acres: 4519},
                    { habtype: "Wetland", Acres: 3271} ]);
                [Bindable]
                private var nep24:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 1},
                    { habtype: "Coral Reef", Acres: 0.13},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 1},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 10} ]);
                [Bindable]
                private var nep25:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 1.6},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 7},
                    { habtype: "Riparian", Acres: 100},
                    { habtype: "Upland", Acres: 6.2},
                    { habtype: "Wetland", Acres: 0} ]);
                [Bindable]
                private var nep26:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 5.5},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 4.5},
                    { habtype: "Estuarine Shoreline", Acres: 15},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 82},
                    { habtype: "Wetland", Acres: 40} ]);
                [Bindable]
                private var nep27:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 5.1},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 23},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 4.8},
                    { habtype: "Mangrove", Acres: 3.5},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 1221},
                    { habtype: "Wetland", Acres: 17.4}]);   
                [Bindable]
                private var nep28:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 67},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 2},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 31.33},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 74.24}]);               
                private function displayAcres(data:Object, field:String, index:Number, percentValue:Number):String {
                    var temp:String= (" " + percentValue).substr(0,6);
                    return data.habtype + ": " + '\n ' + data.Acres + " Acres" + '\n ' + temp + "%";
                //Export to PNG information
                private function saveImageAs(event:MouseEvent):void
                    var bd:BitmapData = new BitmapData(cChart.width,cChart.height);
                    bd.draw(cChart);
                    var png:PNGEncoder = new PNGEncoder();
                    var ba:ByteArray = png.encode(bd);
                    var fr:FileReference = new FileReference();
                    fr.save(ba, "nepfy11-piechart.png");
            ]]>
        </mx:Script>
        <!--mx:SeriesInterpolate id="chartChange" duration="2000" /-->
        <mx:Panel id="cChart" title="2011 Habitat Efforts" width="825" height="600" chromeColor="#527EAC" layout="vertical" color="#FFFFFF" verticalGap="10" x="15" y="15">
            <mx:HBox width="400" height="20">
                <mx:ComboBox id="filterCombo" x="140" y="140" change="changeEvt(event)" color="#000000" >
                    <mx:String>Select NEP</mx:String>
                    <mx:String>Albemarle-Pamlico Estuary Program</mx:String>
                    <mx:String>Barataria-Terrebonne Estuary Program</mx:String>
                    <mx:String>Barnegat Bay Estuary Program</mx:String>
                    <mx:String>Buzzards Bay National Estuary Program</mx:String>
                    <mx:String>Casco Bay Estuary Partnership</mx:String>
                    <mx:String>Charlotte Harbor Estuary Program</mx:String>
                    <mx:String>Coastal Bend Bays and Estuaries Program</mx:String>
                    <mx:String>Delaware Estuary Program</mx:String>
                    <mx:String>Delaware Inland Bays Estuary Program</mx:String>
                    <mx:String>Galveston Bay Estuary Program</mx:String>
                    <mx:String>Indian River Lagoon NEP</mx:String>
                    <mx:String>Long Island Sound Study</mx:String>
                    <mx:String>Lower Columbia River Estuary</mx:String>
                    <mx:String>Maryland Coastal Bays Program</mx:String>
                    <mx:String>Massachusetts Bays NEP</mx:String>
                    <mx:String>Mobile Bay Estuary Program</mx:String>
                    <mx:String>Morro Bay Estuary Program</mx:String>
                    <mx:String>Narragansett Bay Estuary Program</mx:String>
                    <mx:String>New York-New Jersey Harbor Estuary Program</mx:String>
                    <mx:String>Peconic Estuary Program</mx:String>
                    <mx:String>Piscataqua Region Estuaries Partnership</mx:String>
                    <mx:String>Puget Sound Partnership</mx:String>
                    <mx:String>San Francisco Estuary Project</mx:String>
                    <mx:String>San Juan Bay NEP</mx:String>
                    <mx:String>Santa Monica Bay Restoration Project</mx:String>
                    <mx:String>Sarasota Bay Estuary Program</mx:String>
                    <mx:String>Tampa Bay Estuary Program</mx:String>
                    <mx:String>Tillamook Estuaries Partnership</mx:String>
                </mx:ComboBox>
            </mx:HBox>
            <mx:HBox horizontalGap="20" width="822" height="535">
                <mx:PieChart id="chart" showDataTips="true" dataProvider="{ds}" width="634"  height="534" paddingTop="10" fontSize="9" fontFamily="Arial" color="#000000" textAlign="left">
                    <mx:series>
                        <mx:PieSeries id="seriesId" explodeRadius="0.06" nameField="habtype" labelPosition="callout" color="#000000" insideLabelSizeLimit="8" field="Acres" labelFunction="displayAcres">
                        </mx:PieSeries>
                    </mx:series>
                </mx:PieChart>
                <mx:Legend dataProvider="{chart}" dropShadowVisible="true" width="150" color="#000000" height="350" chromeColor="#527EAC" borderColor="#527EAC" direction="vertical"/>          
            </mx:HBox>
        </mx:Panel>
        <mx:Button x="734" y="623" label="Export Pie Chart" id="btnSnap" click="saveImageAs(event)"/>
        <mx:Button x="444" y="623" label="PDF" click="savePDF(event)" />
    </mx:Application>
    Thank you in advance,
    Alison

    I figured it out!!!!! In case anyone else needs to know - here is the working code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="650" width="850">
        <mx:Script>
            <![CDATA[
                import flash.events.Event;
                import mx.collections.ArrayCollection;
                import mx.controls.Alert;
                import mx.events.*;
                import mx.events.DropdownEvent;
                import mx.graphics.codec.PNGEncoder;
                import org.alivepdf.display.*;
                import org.alivepdf.fonts.*;
                import org.alivepdf.images.ColorSpace;
                import org.alivepdf.images.PDFImage;
                import org.alivepdf.layout.*;
                import org.alivepdf.pdf.*;
                import org.alivepdf.saving.*;
                //PDF Export information
                private var pdf:PDF;
                private function savePDF(event:MouseEvent): void {
                    pdf = new PDF(Orientation.LANDSCAPE, Unit.MM, Size.LETTER);
                    pdf.setDisplayMode(Display.FULL_WIDTH);
                    pdf.addPage();
                    var bd:BitmapData = new BitmapData(cChart.width,cChart.height);
                    bd.draw(cChart);
                    var bm:Bitmap=new Bitmap(bd);
                    //bm.x=825;
                    //bm.y=600;
                    //bm.width=825;
                    pdf.setMargins(0, 2, 0, 0);
                    pdf.addImage(bm, new Resize (Mode.RESIZE_PAGE, Position.CENTERED));
                    //pdf.setXY(10,95);
                    var bytes:ByteArray=pdf.save(Method.LOCAL);
                    var fr:FileReference=new FileReference();
                    fr.save(bytes,"nep_piefy11.pdf");
                //Pie Chart Creation information
                [Bindable]
                public var ds:ArrayCollection = sel;
                private function changeEvt(event:Event):void {
                    if(filterCombo.selectedItem == 'Select NEP') {ds = sel;}
                    if(filterCombo.selectedItem == 'Albemarle-Pamlico Estuary Program') {ds = nep1;}
                    if(filterCombo.selectedItem == 'Barataria-Terrebonne Estuary Program') {ds = nep2;}
                    if(filterCombo.selectedItem == 'Barnegat Bay Estuary Program') {ds = nep3;}
                    if(filterCombo.selectedItem == 'Buzzards Bay National Estuary Program') {ds = nep4;}
                    if(filterCombo.selectedItem == 'Casco Bay Estuary Partnership') {ds = nep5;}
                    if(filterCombo.selectedItem == 'Charlotte Harbor Estuary Program') {ds = nep6;}
                    if(filterCombo.selectedItem == 'Coastal Bend Bays and Estuaries Program') {ds = nep7;}
                    if(filterCombo.selectedItem == 'Delaware Estuary Program') {ds = nep8;}
                    if(filterCombo.selectedItem == 'Delaware Inland Bays Estuary Program') {ds = nep9;}
                    if(filterCombo.selectedItem == 'Galveston Bay Estuary Program') {ds = nep10;}
                    if(filterCombo.selectedItem == 'Indian River Lagoon NEP') {ds = nep11;}
                    if(filterCombo.selectedItem == 'Long Island Sound Study') {ds = nep12;}
                    if(filterCombo.selectedItem == 'Lower Columbia River Estuary') {ds = nep13;}
                    if(filterCombo.selectedItem == 'Maryland Coastal Bays Program') {ds = nep14;}
                    if(filterCombo.selectedItem == 'Massachusetts Bays NEP') {ds = nep15;}
                    if(filterCombo.selectedItem == 'Mobile Bay Estuary Program') {ds = nep16;}
                    if(filterCombo.selectedItem == 'Morro Bay Estuary Program') {ds = nep17;}
                    if(filterCombo.selectedItem == 'Narragansett Bay Estuary Program') {ds = nep18;}
                    if(filterCombo.selectedItem == 'New York-New Jersey Harbor Estuary Program') {ds = nep19;}
                    if(filterCombo.selectedItem == 'Peconic Estuary Program') {ds = nep20;}
                    if(filterCombo.selectedItem == 'Piscataqua Region Estuaries Partnership') {ds = nep21;}
                    if(filterCombo.selectedItem == 'Puget Sound Partnership') {ds = nep22;}
                    if(filterCombo.selectedItem == 'San Francisco Estuary Project') {ds = nep23;}
                    if(filterCombo.selectedItem == 'San Juan Bay NEP') {ds = nep24;}
                    if(filterCombo.selectedItem == 'Santa Monica Bay Restoration Project') {ds = nep25;}
                    if(filterCombo.selectedItem == 'Sarasota Bay Estuary Program') {ds = nep26;}
                    if(filterCombo.selectedItem == 'Tampa Bay Estuary Program') {ds = nep27;}
                    if(filterCombo.selectedItem == 'Tillamook Estuaries Partnership') {ds = nep28;}
                [Bindable]
                private var sel:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0.5},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 0} ]);
                [Bindable]
                private var nep1:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 778.44},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0.45},
                    { habtype: "Estuarine Shoreline", Acres: 1276.30},
                    { habtype: "Instream", Acres: 1.0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0.75},
                    { habtype: "Upland", Acres: 779.74},
                    { habtype: "Wetland", Acres: 3268.31} ]);
                [Bindable]
                private var nep2:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 7.25},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 1185} ]);
                [Bindable]
                private var nep3:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 35.21},
                    { habtype: "Upland", Acres: 852.57},
                    { habtype: "Wetland", Acres: 197.82} ]);
                [Bindable]
                private var nep4:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 751.82},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 321.82},
                    { habtype: "Wetland", Acres: 157.35} ]);
                [Bindable]
                private var nep5:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 217},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 324.5},
                    { habtype: "Wetland", Acres: 0} ]);
                [Bindable]
                private var nep6:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 1268},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 50},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 61},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 809},
                    { habtype: "Wetland", Acres: 1690} ]);
                [Bindable]
                private var nep7:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 726} ]);
                [Bindable]
                private var nep8:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0.28},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 82},
                    { habtype: "Estuarine Shoreline", Acres: 0.14},
                    { habtype: "Instream", Acres: 2.3},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 643},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 501.9},
                    { habtype: "Upland", Acres: 148.71},
                    { habtype: "Wetland", Acres: 2586.02} ]);
                [Bindable]
                private var nep9:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 26.21},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 37},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 27},
                    { habtype: "Wetland", Acres: 646} ]);
                [Bindable]
                private var nep10:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 2868},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 407.06} ]);
                [Bindable]
                private var nep11:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 5},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 3},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 43},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 12910.5},
                    { habtype: "Wetland", Acres: 5026} ]);
                [Bindable]
                private var nep12:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 67},
                    { habtype: "Beach/Dune", Acres: 21.95},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 120.72},
                    { habtype: "Wetland", Acres: 151.08} ]);
                [Bindable]
                private var nep13:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 12},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 194},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 200} ]);
                [Bindable]
                private var nep14:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 58},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 153},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 494.3},
                    { habtype: "Wetland", Acres: 0} ]);
                [Bindable]
                private var nep15:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 1313},
                    { habtype: "Estuarine Shoreline", Acres: 8},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 543.8} ]);
                [Bindable]
                private var nep16:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 40},
                    { habtype: "Estuarine Shoreline", Acres: 6.5},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 195},
                    { habtype: "Wetland", Acres: 85} ]);
                [Bindable]
                private var nep17:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 1109.9},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 1.14},
                    { habtype: "Estuarine Shoreline", Acres: 0.28},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0.71},
                    { habtype: "Wetland", Acres: 0} ]);
                [Bindable]
                private var nep18:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 1099},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 0} ]);
                [Bindable]
                private var nep19:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 101.3} ]);
                [Bindable]
                private var nep20:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 98.72},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 17.99},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 106.13},
                    { habtype: "Wetland", Acres: 12.97} ]);
                [Bindable]
                private var nep21:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 9},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 3},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 2},
                    { habtype: "Upland", Acres: 1451},
                    { habtype: "Wetland", Acres: 27} ]);
                [Bindable]
                private var nep22:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 26},
                    { habtype: "Beach/Dune", Acres: 1.65},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 240.39},
                    { habtype: "Estuarine Shoreline", Acres: 314.97},
                    { habtype: "Instream", Acres: 505.87},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 1450.47},
                    { habtype: "Upland", Acres: 1176.7},
                    { habtype: "Wetland", Acres: 850.58} ]);
                [Bindable]
                private var nep23:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 43.05},
                    { habtype: "Upland", Acres: 4519},
                    { habtype: "Wetland", Acres: 3271} ]);
                [Bindable]
                private var nep24:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 1},
                    { habtype: "Coral Reef", Acres: 0.13},
                    { habtype: "Estuarine", Acres: 0},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 1},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 10} ]);
                [Bindable]
                private var nep25:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 1.6},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 7},
                    { habtype: "Riparian", Acres: 100},
                    { habtype: "Upland", Acres: 6.2},
                    { habtype: "Wetland", Acres: 0} ]);
                [Bindable]
                private var nep26:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 5.5},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 4.5},
                    { habtype: "Estuarine Shoreline", Acres: 15},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 82},
                    { habtype: "Wetland", Acres: 40} ]);
                [Bindable]
                private var nep27:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 0},
                    { habtype: "Beach/Dune", Acres: 5.1},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 23},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 4.8},
                    { habtype: "Mangrove", Acres: 3.5},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 0},
                    { habtype: "Upland", Acres: 1221},
                    { habtype: "Wetland", Acres: 17.4}]);   
                [Bindable]
                private var nep28:ArrayCollection = new ArrayCollection( [
                    { habtype: "Agriculture/Ranch Land", Acres: 67},
                    { habtype: "Beach/Dune", Acres: 0},
                    { habtype: "Coral Reef", Acres: 0},
                    { habtype: "Estuarine", Acres: 2},
                    { habtype: "Estuarine Shoreline", Acres: 0},
                    { habtype: "Instream", Acres: 0},
                    { habtype: "Island", Acres: 0},
                    { habtype: "Lake/Pond", Acres: 0},
                    { habtype: "Mangrove", Acres: 0},
                    { habtype: "Other", Acres: 0},
                    { habtype: "Riparian", Acres: 31.33},
                    { habtype: "Upland", Acres: 0},
                    { habtype: "Wetland", Acres: 74.24}]);               
                private function displayAcres(data:Object, field:String, index:Number, percentValue:Number):String {
                    var temp:String= (" " + percentValue).substr(0,6);
                    return data.habtype + ": " + '\n ' + data.Acres + " Acres" + '\n ' + temp + "%";
                //Export to PNG information
                private function saveImageAs(event:MouseEvent):void
                    var bd:BitmapData = new BitmapData(cChart.width,cChart.height);
                    bd.draw(cChart);
                    var png:PNGEncoder = new PNGEncoder();
                    var ba:ByteArray = png.encode(bd);
                    var fr:FileReference = new FileReference();
                    fr.save(ba, "nepfy11-piechart.png");
            ]]>
        </mx:Script>
        <!--mx:SeriesInterpolate id="chartChange" duration="2000" /-->
        <mx:Panel id="cChart" title="2011 Habitat Efforts" width="825" height="600" chromeColor="#527EAC" layout="vertical" color="#FFFFFF" verticalGap="10" x="15" y="15">
            <mx:HBox width="400" height="20">
                <mx:ComboBox id="filterCombo" x="140" y="140" change="changeEvt(event)" color="#000000" >
                    <mx:String>Select NEP</mx:String>
                    <mx:String>Albemarle-Pamlico Estuary Program</mx:String>
                    <mx:String>Barataria-Terrebonne Estuary Program</mx:String>
                    <mx:String>Barnegat Bay Estuary Program</mx:String>
                    <mx:String>Buzzards Bay National Estuary Program</mx:String>
                    <mx:String>Casco Bay Estuary Partnership</mx:String>
                    <mx:String>Charlotte Harbor Estuary Program</mx:String>
                    <mx:String>Coastal Bend Bays and Estuaries Program</mx:String>
                    <mx:String>Delaware Estuary Program</mx:String>
                    <mx:String>Delaware Inland Bays Estuary Program</mx:String>
                    <mx:String>Galveston Bay Estuary Program</mx:String>
                    <mx:String>Indian River Lagoon NEP</mx:String>
                    <mx:String>Long Island Sound Study</mx:String>
                    <mx:String>Lower Columbia River Estuary</mx:String>
                    <mx:String>Maryland Coastal Bays Program</mx:String>
                    <mx:String>Massachusetts Bays NEP</mx:String>
                    <mx:String>Mobile Bay Estuary Program</mx:String>
                    <mx:String>Morro Bay Estuary Program</mx:String>
                    <mx:String>Narragansett Bay Estuary Program</mx:String>
                    <mx:String>New York-New Jersey Harbor Estuary Program</mx:String>
                    <mx:String>Peconic Estuary Program</mx:String>
                    <mx:String>Piscataqua Region Estuaries Partnership</mx:String>
                    <mx:String>Puget Sound Partnership</mx:String>
                    <mx:String>San Francisco Estuary Project</mx:String>
                    <mx:String>San Juan Bay NEP</mx:String>
                    <mx:String>Santa Monica Bay Restoration Project</mx:String>
                    <mx:String>Sarasota Bay Estuary Program</mx:String>
                    <mx:String>Tampa Bay Estuary Program</mx:String>
                    <mx:String>Tillamook Estuaries Partnership</mx:String>
                </mx:ComboBox>
            </mx:HBox>
            <mx:HBox horizontalGap="20" width="822" height="535">
                <mx:PieChart id="chart" showDataTips="true" dataProvider="{ds}" width="634"  height="534" paddingTop="10" fontSize="9" fontFamily="Arial" color="#000000" textAlign="left">
                    <mx:series>
                        <mx:PieSeries id="seriesId" explodeRadius="0.06" nameField="habtype" labelPosition="callout" color="#000000" insideLabelSizeLimit="8" field="Acres" labelFunction="displayAcres">
                        </mx:PieSeries>
                    </mx:series>
                </mx:PieChart>
                <mx:Legend dataProvider="{chart}" dropShadowVisible="true" width="150" color="#000000" height="350" chromeColor="#527EAC" borderColor="#527EAC" direction="vertical"/>          
            </mx:HBox>
        </mx:Panel>
        <mx:Button x="746" y="623" label="Export to PNG" id="btnSnap" click="saveImageAs(event)"/>
        <mx:Button x="651" y="623" label="Export to PDF" click="savePDF(event)" />
    </mx:Application>
    Thanks, Alison

  • How to load and display a byte array (jpeg) image file dynamically in Flex?

    My web service client (servlet) received a binary jpeg data from an Image Server. The Flex application invokes the
    servlet via HttpService and receives the binary jpeg data as byte array.  How could it be displayed dynamically
    without writing the byte array to a jpeg file?  Please help (some sample code is very much appreciated).

    JPEGEncoder is only useful for converting BitmapData to ByteArray, not the other way around.
    By the way JPEGEncoder and PNGEncoder are part of the Flex SDK now, so no need to use AS3Lib (alltough it's a good library to have around).
    To display/use a ByteArray as image, use a Loader instance with the loadBytes method.
        Loader.loadBytes(bytes:ByteArray, context:LoaderContext = null);
    Listen for the complete event on the Loader.contentLoaderInfo and get the BitmapData in the event handler.
    private function loadJpeg():void {
        var loader:Loader = new Loader();
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteHandler);
        //jpgBA is the ByteArray loaded from webservice
        loader.loadBytes(jpgBA);
    private function loaderCompleteHandler(evt:Event):void {
        var t:LoaderInfo = evt.currentTarget as LoaderInfo;
        // display the jpeg in an Image component
        img.source = t.content;
    <mx:Image id="img" scaleContent="false" />

  • Using jpegEncoder object and filesystem

    Hi, I also posted this in the Flex general forum, but it
    seems to be more AIR related since it deals with saving to the
    local disk. I am trying to create a simple AIR application that
    creates a thumbnail from an image component and saves it as a jpeg
    to the desktop. I am not sure where I am going wrong here, but the
    file is corrupt and no information is being written to it. If I
    look at the content (via the "more" command on the command line) it
    is 8 blank lines.
    Thanks so much,
    Jed
    =========
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical">
    <mx:Script>
    <![CDATA[
    import mx.graphics.ImageSnapshot;
    import mx.graphics.codec.*;
    import mx.events.FileEvent;
    private function captureImg():void{
    //captures the image as a jpg and saves it to the desktop
    var codec:JPEGEncoder = new JPEGEncoder();
    //var ba:ByteArray = new ByteArray;
    var file:File =
    File.desktopDirectory.resolvePath("test.jpg");
    var filestream:FileStream = new FileStream;
    var snapShot:ImageSnapshot = new ImageSnapshot;
    snapShot = ImageSnapshot.captureImage(bigImg,72,codec);
    filestream.open(file, FileMode.WRITE);
    filestream.writeBytes(
    codec.encodeByteArray(snapShot.data,420,120),0,snapShot.data.length);
    filestream.close();
    private function makeSmall():void{
    //makes the image on the screen thumbnail size
    var pic:Image = bigImg;
    pic.setActualSize(420, 120);
    ]]>
    </mx:Script>
    <mx:VBox horizontalAlign="center" verticalAlign="top">
    <mx:Image id="bigImg" width="480" height="320"
    source="orignial/test2.jpg"/>
    <mx:Button label="Reduce Size" id="btnSmaller"
    click="makeSmall();" />
    <mx:Button label="Snap Thumbnail" id="btnThumbnail"
    click="captureImg();"/>
    </mx:VBox>
    </mx:WindowedApplication>
    Text

    Well I didn't get any feedback here on this problem. But I
    did figure it out.
    ===============
    <mx:WindowedApplication xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical">
    <mx:Script>
    <![CDATA[
    import flash.display.BitmapData;
    import mx.graphics.codec.JPEGEncoder;
    import flash.filesystem.*;
    private function captureImg():void{
    ** A bitmapData object is needed to contain the visual data
    var bmpd:BitmapData = new BitmapData(
    smallImg.width,smallImg.height, false, 0xFFFFFF);
    bmpd.draw(smallImg);
    ** the bitmapdata object needs to be encoded into an
    byteArray with
    ** the JPEGEncoder. there is also a PNGEncoder for .png
    files if wanted
    ** The paramerter passed is the quality of jpeg we are
    encoding, 50 - 100.
    var jpegEnc:JPEGEncoder = new JPEGEncoder(80);
    var ba:ByteArray = jpegEnc.encode(bmpd);
    ** Then we need to take the byteArray and save it to disk.
    ** this requries using a File and fileStream object. The try
    block
    ** catches the end of file error.
    var file:File =
    new
    File("file:///Developer/Flex/thumbnailDemo/src/thumbnail/thumb1.jpg");
    var filestream:FileStream = new FileStream();
    try{
    filestream.open(file, FileMode.WRITE);
    filestream.writeBytes(ba);
    filestream.close();
    }catch (e:Error){
    trace(e.message);
    filePath.text = file.name + " has been saved to " +
    file.nativePath;
    filePath.enabled = true;
    ** makeSmall reduces the size of the main image and places
    it in
    ** the smallImg component to await capture
    private function makeSmall():void{
    //makes the image on the screen thumbnail size
    var pic:Image = bigImg;
    var otherPic:Image = smallImg;
    smallImg.source = bigImg.source;
    otherPic.setActualSize(120, 80);
    ** loadThumb loads the saved thumbnail to the savedPic
    component
    private function loadThumb():void{
    var thumb:File =
    new
    File("file:///Developer/Flex/thumbnailDemo/src/thumbnail/thumb1.jpg");
    if (thumb.exists){
    var src:File = new
    File("file:///Developer/Flex/thumbnailDemo/src/");
    var relPath:String = src.getRelativePath(thumb);
    savedPic.source = relPath;
    filePath.text = "The Thumbnail has been sucessfully loaded
    from "
    + thumb.nativePath;
    ]]>
    </mx:Script>
    <mx:VBox horizontalAlign="left" verticalAlign="top">
    <mx:HBox>
    <mx:Image id="bigImg" width="480" height="320"
    source="orignial/test2.jpg"/>
    <mx:VBox verticalAlign="top" horizontalAlign="center">
    <mx:Label text="Thumbnail"/>
    <mx:Image id="smallImg" width="120" height="80" />
    <mx:Label text="Saved Thumbnail" />
    <mx:Image id="savedPic" width="120" height="80" />
    </mx:VBox>
    </mx:HBox>
    <mx:HBox horizontalAlign="left">
    <mx:Button label="Reduce Size" id="btnSmaller"
    click="makeSmall();" />
    <mx:Button label="Snap Thumbnail" id="btnThumbnail"
    click="captureImg();"/>
    <mx:Button label="Load Thumbnail" id="btnLoad"
    click="loadThumb();"/>
    </mx:HBox>
    <mx:Label id="filePath" enabled="false" />
    </mx:VBox>
    </mx:WindowedApplication>

  • Loading, cropping and saving jpg files in Flex

    I'm attempting to apply the code for selecting, cropping and saving image data (.jpg, .png) as shown on the web site:
    http://www.adobe.com/devnet/flash/quickstart/filereference_class_as3.html#articlecontentAd obe_numberedheader_1
    The sample application is contained within a class called Crop contained in the action script file Crop.as which begins as follows:
    package
        import com.adobe.images.JPGEncoder;
        import com.adobe.images.PNGEncoder;
        import flash.display.BitmapData;
        import flash.display.DisplayObject;
        import flash.display.DisplayObjectContainer;
        import flash.display.Loader;
        import flash.display.LoaderInfo;
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.IOErrorEvent;
        import flash.events.MouseEvent;
        import flash.geom.Matrix;
        import flash.geom.Rectangle;
        import flash.net.FileFilter;
        import flash.net.FileReference;
        import flash.utils.ByteArray;
        public class Crop extends Sprite
    My application attempts to make use of the Crop class by including the Crop.as file:
         <mx:Script source="Crop.as"/> 
    in the Flex Component which needs it, and then calling the Crop constructor to perform the methods of the class
       var localImage:Crop = new Crop();
       localImage.Crop();
    My application does not compile. The package statement (or the curly bracket on the following line) is flagged with the error "Packages may not be nested".
    I have no idea why this should be as I cannot see any nested definitions anywhere in my application. The component includes the Crop.as file which contains the package and class definition.
    Can anyone give my some guidance as to why this error is occurring?
    Any help would be greatly appreciated.  

    Hi Scott,
    #1
    that error is because "fx:Script" (or mx:Script) are intended to include part of Actionscript code - but not class defitions or blocks.
    So if you are trying to include e.g. such class:
    package
         import flash.display.Sprite;
         public class Crop extends Sprite
              public function Crop()
                   super();
              public function processImage():void
                   trace("processImage()");
    compiler will immediately complain as you are trying to incorporate nested class within your application code.
    #2
    here is correct way (I think) to incorporate some class via mxml tags (here using fx:Script):
    Using class sample above:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                      xmlns:s="library://ns.adobe.com/flex/spark"
                      xmlns:mx="library://ns.adobe.com/flex/mx"
                      xmlns:utils="*"
                      applicationComplete="completeHandler(event)">
         <!-- util Crop will be initialized here as instance "cropUtil" -->
         <fx:Declarations>
              <utils:Crop id="cropUtil"/>
         </fx:Declarations>
         <!-- script where "cropUtil" will be used -->
         <fx:Script>
              <![CDATA[
                   import mx.events.FlexEvent;
                   protected function completeHandler(event:FlexEvent):void
                        cropUtil.processImage();
              ]]>
         </fx:Script>
    </s:Application>
    But note that you could simply create instance of your class by direct import in fx:Script:
         <fx:Script>
              <![CDATA[
                   import mx.events.FlexEvent;
                   private var cropUtil:Crop = null;
                   protected function completeHandler(event:FlexEvent):void
                        cropUtil = new Crop();
                        cropUtil.processImage();
              ]]>
         </fx:Script>
    hth,
    kind regards,
    Peter Blazejewicz

  • A litle help please...  drawing app.

    Hi all,
    I'm trying to adapt a file I downloaded (legally) and I'm having some trouble as I'm still stuck in the days of AS2 and this has
    been built in AS3. As you will see it's a drawing app that allows a few options for brush size, blur etc.,
    What I'd like to do is to duplicate the brush_tool_mc  with settings for full brush size and full blur to use as a spray can tool.
    All my attempts so far have ended in disaster and multiple output errors !  : (
    Any help / pointers / guidance much appreciated.
    Best wishes
    Tony
    Source and example is here:
    http://www.nocircleno.com/graffiti/examples/2.x/graffiti_advanced_demo.html
    CODE:  (Main.as)
    *      Example Application built with the Graffiti Library
    *      www.nocircleno.com/graffiti/
    *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
    *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    *     OTHER DEALINGS IN THE SOFTWARE.
    package {
        import flash.display.Bitmap;
        import flash.display.BitmapData
        import flash.display.MovieClip;
        import flash.display.SimpleButton;
        import flash.display.Sprite;
        import flash.display.LineScaleMode;
        import flash.display.CapsStyle;
        import flash.display.JointStyle;
        import flash.text.TextField;
        import flash.geom.Point;
        import flash.text.TextFormat;
        import flash.ui.Keyboard;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.events.KeyboardEvent;
        import flash.display.BlendMode;
        import flash.net.navigateToURL;
        import flash.net.FileReference;
        import flash.net.URLRequest;
        import flash.net.URLRequestMethod;
        import flash.net.URLRequestHeader;
        import flash.text.Font;
        import flash.utils.ByteArray;
        import fl.controls.CheckBox;
        import fl.controls.ColorPicker;
        import fl.controls.Slider;
        import fl.controls.ComboBox;
        import fl.events.ColorPickerEvent;
        import fl.events.SliderEvent;
        import fl.data.DataProvider;
        import com.nocircleno.graffiti.GraffitiCanvas;
        import com.nocircleno.graffiti.display.Text;
        import com.nocircleno.graffiti.display.GraffitiObject;
        import com.nocircleno.graffiti.events.CanvasEvent;
        import com.nocircleno.graffiti.events.GraffitiObjectEvent;
        import com.nocircleno.graffiti.tools.BrushTool;
        import com.nocircleno.graffiti.tools.BrushType;
        import com.nocircleno.graffiti.tools.LineTool;
        import com.nocircleno.graffiti.tools.LineType;
        import com.nocircleno.graffiti.tools.ShapeTool;
        import com.nocircleno.graffiti.tools.ShapeType;
        import com.nocircleno.graffiti.tools.ToolMode;
        import com.nocircleno.graffiti.tools.ITool;
        import com.nocircleno.graffiti.tools.BitmapTool;
        import com.nocircleno.graffiti.tools.FillBucketTool;
        import com.nocircleno.graffiti.tools.SelectionTool;
        import com.nocircleno.graffiti.tools.TextSettings;
        import com.nocircleno.graffiti.tools.TextTool;
        import com.nocircleno.graffiti.managers.GraffitiObjectManager;
        import com.adobe.images.PNGEncoder;
        public class Main extends MovieClip {
            public var click_message_txt:TextField;
            // ui
            public var brush_tool_mc:ItemButton;
            public var eraser_tool_mc:ItemButton;
            public var line_tool_mc:ItemButton;
            public var rectangle_tool_mc:ItemButton;
            public var fillbucket_tool_mc:ItemButton;
            public var selection_tool_mc:ItemButton;
            public var text_tool_mc:ItemButton;
            public var oval_tool_mc:ItemButton;
            public var clear_btn:SimpleButton;
            public var save_btn:SimpleButton;
            public var undo_btn:SimpleButton;
            public var redo_btn:SimpleButton;
            public var slider_label_txt:TextField;
            public var slider_2_label_txt:TextField;
            public var slider_3_label_txt:TextField;
            public var combo_label_txt:TextField;
            public var stroke_color_mc:ColorPicker;
            public var fill_color_mc:ColorPicker;
            public var slider_mc:Slider;
            public var slider_2_mc:Slider;
            public var slider_3_mc:Slider;
            public var zoom_slider_mc:Slider;
            public var combo_list:ComboBox;
            public var overlay_cb:CheckBox;
            public var overlay_mc:MovieClip;
            public var canvas:GraffitiCanvas;
            public var border:Sprite;
            // tools
            private var _brush:BrushTool;
            private var _eraser:BrushTool;
            private var _line:LineTool;
            private var _shape:ShapeTool;
            private var _selectionTool:SelectionTool;
            private var _textTool:TextTool;
            private var _fillBucketTool:FillBucketTool;
            // props
            private var _brushSize:Number = 2;
            private var _strokeColor:uint = 0x00FF00;
            private var _fillColor:uint = 0xFF0000;
            private var _strokeAlpha:Number = 1;
            private var _fillAlpha:Number = 1;
            private var _brushBlur:Number = 0;
            private var _fontColor:uint = 0x00FF00;
            private var _fontSize:uint = 14;
            private var _brushShapeIndex:int;
            private var _lineStyleIndex:int;
            private var _fontIndex:uint = 0;
            private var _fontList:DataProvider;
            private var _brushShapes:DataProvider;
            private var _lineStyles:DataProvider;
            private var _fileRef:FileReference;
            private var _objectManager:GraffitiObjectManager;
            private var _orginalComboBoxItemsPos = new Object();
            public function Main() {
                // hide message
                click_message_txt.alpha = 0;
                // create canvas
                canvas = new GraffitiCanvas(840, 470, 10);
                canvas.x = 0;
                canvas.y = 120;
                canvas.addEventListener(MouseEvent.MOUSE_WHEEL, scrollHandler);
                canvas.addEventListener(GraffitiCanvas.HISTORY_LENGTH_CHANGE, historyLengthChangeHandler);
                canvas.addEventListener(GraffitiObjectEvent.SELECT, objectEventHandler);
                canvas.addEventListener(GraffitiObjectEvent.ENTER_EDIT, objectEventHandler);
                addChild(canvas);
                // add image over canvas
                overlay_mc = new OverlayImage();
                canvas.overlay = overlay_mc;
                // get instance of graffiti object manager
                _objectManager = GraffitiObjectManager.getInstance();
                // add listeners for keyboard shortcuts
                stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
                stage.addEventListener(KeyboardEvent.KEY_UP, keyHandler);
                // add event listeners for tool buttons
                selection_tool_mc.addEventListener(MouseEvent.CLICK, toolHandler);
                text_tool_mc.addEventListener(MouseEvent.CLICK, toolHandler);
                fillbucket_tool_mc.addEventListener(MouseEvent.CLICK, toolHandler);
                brush_tool_mc.addEventListener(MouseEvent.CLICK, toolHandler);
                eraser_tool_mc.addEventListener(MouseEvent.CLICK, toolHandler);
                line_tool_mc.addEventListener(MouseEvent.CLICK, toolHandler);
                rectangle_tool_mc.addEventListener(MouseEvent.CLICK, toolHandler);
                oval_tool_mc.addEventListener(MouseEvent.CLICK, toolHandler);
                // setup data providers
                _brushShapes = new DataProvider();
                _brushShapes.addItem({label:"Round", data: BrushType.ROUND});
                _brushShapes.addItem({label:"Square", data: BrushType.SQUARE});
                _brushShapes.addItem({label:"Diamond", data: BrushType.DIAMOND});
                _brushShapes.addItem({label:"Vertical", data: BrushType.VERTICAL_LINE});
                _brushShapes.addItem({label:"Horizontal", data: BrushType.HORIZONTAL_LINE});
                _brushShapes.addItem({label:"Forward", data: BrushType.FORWARD_LINE});
                _brushShapes.addItem({label:"Backward", data: BrushType.BACKWARD_LINE});
                _lineStyles = new DataProvider();
                _lineStyles.addItem({label:"Solid", data: LineType.SOLID});
                _lineStyles.addItem({label:"Dotted", data: LineType.DOTTED});
                _lineStyles.addItem( { label:"Dashed", data: LineType.DASHED } );
                // Setup Font List
                _fontList = new DataProvider();
                var embeddedFonts:Array = Font.enumerateFonts(true);
                embeddedFonts.sortOn("fontName", Array.CASEINSENSITIVE);
                for (var i:int = 0; i < embeddedFonts.length; i++) {
                    _fontList.addItem( {label: embeddedFonts[i].fontName, data: embeddedFonts[i] } );
                // create tool instances
                _brush = new BrushTool(_brushSize, _fillColor, _fillAlpha, _brushBlur, BrushType.ROUND);
                _eraser = new BrushTool(_brushSize, _fillColor, 1, _brushBlur, BrushType.ROUND, ToolMode.ERASE);
                _line = new LineTool(2, _strokeColor, _strokeAlpha, LineType.SOLID);
                _shape = new ShapeTool(2, _strokeColor, _fillColor, _strokeAlpha, _fillAlpha, ShapeType.RECTANGLE);
                _fillBucketTool = new FillBucketTool(_fillColor, true);
                _selectionTool = new SelectionTool();
                _textTool = new TextTool(new TextSettings(Font(_fontList.getItemAt(0).data), new TextFormat(null, _fontSize, _fontColor)));
                // setup color pickers
                stroke_color_mc.focusEnabled = false;
                stroke_color_mc.selectedColor = _strokeColor;
                stroke_color_mc.addEventListener(ColorPickerEvent.CHANGE, colorPickerHandler);
                stroke_color_mc.enabled = false;
                fill_color_mc.focusEnabled = false;
                fill_color_mc.selectedColor = _fillColor;
                fill_color_mc.addEventListener(ColorPickerEvent.CHANGE, colorPickerHandler);
                slider_mc.addEventListener(SliderEvent.CHANGE, sliderHandler);
                slider_2_mc.addEventListener(SliderEvent.CHANGE, sliderHandler);
                slider_3_mc.addEventListener(SliderEvent.CHANGE, sliderHandler);
                overlay_cb.addEventListener(Event.CHANGE, overlayHandler);
                overlay_cb.focusEnabled = false;
                // config combo list
                combo_list.addEventListener(Event.CHANGE, comboEventHandler);
                combo_list.dataProvider = _brushShapes;
                combo_list.focusEnabled = false;
                // store positions
                _orginalComboBoxItemsPos.comboBox = new Point(combo_list.x, combo_list.y);
                _orginalComboBoxItemsPos.comboBoxLabel = new Point(combo_label_txt.x, combo_label_txt.y);
                // disable undo and redo buttons
                undo_btn.mouseEnabled = false;
                undo_btn.alpha = .5;
                redo_btn.mouseEnabled = false;
                redo_btn.alpha = .5;
                // add event listeners
                undo_btn.addEventListener(MouseEvent.CLICK, historyHandler);
                redo_btn.addEventListener(MouseEvent.CLICK, historyHandler);
                clear_btn.addEventListener(MouseEvent.CLICK, clearCanvasHandler);
                save_btn.addEventListener(MouseEvent.CLICK, saveHandler);
                zoom_slider_mc.maximum = canvas.maxZoom;
                zoom_slider_mc.addEventListener(SliderEvent.CHANGE, zoomHandler);
                // assign the brush tool as the default tool
                canvas.activeTool = _brush;
                // set brush tool
                brush_tool_mc.selected = true;
                setSelectedBrushShape(BrushType.ROUND);
                Method    : objectEventHandler()
                Purpose    : This method handles GraffitiObjectEvents.  We use this
                          to know when an object is selected or enters edit mode.
                Params    : e -- GraffitiObjectEvent object.
            private function objectEventHandler(e:GraffitiObjectEvent):void {
                var font:Font;
                var fmt:TextFormat;
                var i:int;
                if (e.type == GraffitiObjectEvent.SELECT) {
                    // get font and text format of selected object
                    font = Text(e.graffitiObject).textSetting.font;
                    fmt = Text(e.graffitiObject).textSetting.textFormat;
                    _fontSize = Number(fmt.size);
                    var fontFromList:Font;
                    var numberFonts:uint = _fontList.length;
                    // find select text font in font list
                    for (i = 0; i < numberFonts; i++) {
                        fontFromList = Font(_fontList.getItemAt(i).data);
                        if (fontFromList.fontName == font.fontName && fontFromList.fontStyle == font.fontStyle) {
                            _fontIndex = i;
                            break;
                    // if text tool is active tool, then update it.
                    if (canvas.activeTool is TextTool) {   
                        TextTool(canvas.activeTool).textSettings = new TextSettings(font, fmt);
                    } else {
                        _textTool.textSettings.textFormat.size = Number(fmt.size);
                    // update ui for objects
                    combo_list.selectedIndex = _fontIndex;
                    slider_mc.value = Number(fmt.size);   
                    fill_color_mc.selectedColor = uint(fmt.color);
                } else if (e.type == GraffitiObjectEvent.ENTER_EDIT) {
                    // if we enter edit mode on an text object, make sure the tool is set to the text tool.
                    if (e.graffitiObject is Text && !(canvas.activeTool is TextTool)) {
                        setActiveTool(text_tool_mc);
                Method    : overlayHandler()
                Purpose    : This method toggles the overlay on and off.
                Params    : e -- Event object.
            private function overlayHandler(e:Event):void {
                if(e.currentTarget.selected) {
                    canvas.overlay = overlay_mc;
                } else {
                    canvas.overlay = null;
                Method    : historyHandler()
                Purpose    : This method undo or redo the drawing depending on the button
                          clicked by the user.
                Params    : e -- MouseEvent object.
            private function historyHandler(e:MouseEvent):void {
                if(e.currentTarget == undo_btn) {
                    canvas.prevHistory();
                    if(canvas.historyPosition == 0) {
                        undo_btn.mouseEnabled = false;
                        undo_btn.alpha = .5;
                    redo_btn.mouseEnabled = true;
                    redo_btn.alpha = 1;
                } else if(e.currentTarget == redo_btn) {
                    canvas.nextHistory();
                    if(canvas.historyPosition == (canvas.historyLength - 1)) {
                        redo_btn.mouseEnabled = false;
                        redo_btn.alpha = .5;
                    undo_btn.mouseEnabled = true;
                    undo_btn.alpha = 1;
                Method    : clearCanvasHandler()
                Purpose    : This method will clear the canvas.
                Params    : e -- MouseEvent object.
            private function clearCanvasHandler(e:MouseEvent):void {
                canvas.clearCanvas();
                Method    : saveHandler()
                Purpose    : This method will save the drawing as a PNG image.
                Params    : e -- MouseEvent object.
            private function saveHandler(e:MouseEvent):void {
                // get drawing as bitmapdata from the Graffiti Canvas instance.
                var canvasBmp:BitmapData = canvas.drawing();
                // create new jpg encoder object and convert bitmapdata to jpg
                var pngEncoder:PNGEncoder = new PNGEncoder();
                var pngStream:ByteArray = PNGEncoder.encode(canvasBmp);
                // make sure you dispose of the bitmapdata object when finished.
                canvasBmp.dispose();
                _fileRef = new FileReference();
                _fileRef.save(pngStream, "graffiti_example_image.png");
                Method    : historyLengthChangeHandler()
                Purpose    : This method will handle the change in the number of stored
                          history items.  This is used to toggle the redo and undo
                          buttons.
                Params    : e -- Event object.
            private function historyLengthChangeHandler(e:Event):void {
                if(canvas.historyLength > 0 && canvas.historyPosition != 0) {
                    undo_btn.mouseEnabled = true;
                    undo_btn.alpha = 1;
                } else {
                    undo_btn.mouseEnabled = false;
                    undo_btn.alpha = .5;
                if(canvas.historyLength > 0 && canvas.historyPosition != canvas.historyLength - 1) {
                    redo_btn.mouseEnabled = true;
                    redo_btn.alpha = 1;
                } else {
                    redo_btn.mouseEnabled = false;
                    redo_btn.alpha = .5;
                Method    : zoomHandler()
                Purpose    : This method will handle the zoom slider event and set the
                          canvas to the new zoom level.
                Params    : e -- SliderEvent object.
            private function zoomHandler(e:SliderEvent):void {
                // set zoom of canvas
                canvas.zoom = e.value;
                // if canvas is zoomed in then display message about dragging canvas with mouse.
                if(canvas.zoom  > 1) {
                    click_message_txt.alpha = 1;
                } else {
                    click_message_txt.alpha = 0;
                Method    : colorPickerHandler()
                Purpose    : This method will handle the color picker event.
                Params    : e -- ColorPickerEvent object.
            private function colorPickerHandler(e:ColorPickerEvent):void {
                var font:Font;
                var fmt:TextFormat;
                var ts:TextSettings;
                if(canvas.activeTool is BrushTool) {
                    _fillColor = e.color;
                    BrushTool(canvas.activeTool).color = _fillColor;
                } else if(canvas.activeTool is LineTool) {
                    _strokeColor = e.color;
                    LineTool(canvas.activeTool).color = _strokeColor;
                } else if(canvas.activeTool is ShapeTool) {
                    if(e.currentTarget == stroke_color_mc) {
                        _strokeColor = e.color;
                        ShapeTool(canvas.activeTool).strokeColor = _strokeColor;
                    } else if (e.currentTarget == fill_color_mc) {
                        _fillColor = e.color;
                        ShapeTool(canvas.activeTool).fillColor = _fillColor;
                } else if (canvas.activeTool is TextTool) {
                    // update color of textformat object
                    fmt = TextTool(canvas.activeTool).textSettings.textFormat;
                    fmt.color = fill_color_mc.selectedColor;
                    // update text tool
                    TextTool(canvas.activeTool).textSettings.textFormat = fmt;
                    // update any selected text with new color
                    if (_objectManager.areObjectsSelected()) {
                        font = Font(combo_list.selectedItem.data);
                        fmt = new TextFormat(null, slider_mc.value, fill_color_mc.selectedColor);
                        ts = new TextSettings(font, fmt);
                        _objectManager.changeSettingsForSelectedObjects(ts);
                } else if (canvas.activeTool is SelectionTool) {
                    font = Font(combo_list.selectedItem.data);
                    fmt = new TextFormat(null, slider_mc.value, fill_color_mc.selectedColor);
                    ts = new TextSettings(font, fmt);
                    // update text tool
                    _textTool.textSettings = ts;
                    if (_objectManager.areObjectsSelected()) {
                        // change settings for selected text
                        _objectManager.changeSettingsForSelectedObjects(ts);
                } else if (canvas.activeTool is FillBucketTool) {
                    FillBucketTool(canvas.activeTool).fillColor = fill_color_mc.selectedColor;
                Method    : sliderHandler()
                Purpose    : This method will handle the slider change.
                Params    : e -- SliderEvent object.
            private function sliderHandler(e:SliderEvent):void {
                var font:Font;
                var fmt:TextFormat;
                var ts:TextSettings;
                if(e.currentTarget == slider_mc) {
                    if(canvas.activeTool == _brush || canvas.activeTool == _eraser) {
                        _brushSize = e.value;
                        BrushTool(canvas.activeTool).size = _brushSize;
                    } else if(canvas.activeTool == _line) {
                        LineTool(canvas.activeTool).lineWidth = e.value;
                    } else if(canvas.activeTool == _shape) {
                        ShapeTool(canvas.activeTool).strokeWidth = e.value;
                    } else if (canvas.activeTool is TextTool) {
                        _fontSize = slider_mc.value;
                        fmt = TextTool(canvas.activeTool).textSettings.textFormat;
                        fmt.size = slider_mc.value;
                        TextTool(canvas.activeTool).textSettings.textFormat = fmt;
                        if (_objectManager.areObjectsSelected()) {
                            font = Font(combo_list.selectedItem.data);
                            fmt = new TextFormat(null, slider_mc.value, fill_color_mc.selectedColor);
                            ts = new TextSettings(font, fmt);
                            _objectManager.changeSettingsForSelectedObjects(ts);
                    } else if (canvas.activeTool == _selectionTool) {
                        _fontSize = slider_mc.value;
                        font = Font(combo_list.selectedItem.data);
                        fmt = new TextFormat(null, slider_mc.value, fill_color_mc.selectedColor);
                        ts = new TextSettings(font, fmt);
                        // update text tool
                        _textTool.textSettings = ts;
                        if (_objectManager.areObjectsSelected()) {
                            _objectManager.changeSettingsForSelectedObjects(ts);
                } else if(e.currentTarget == slider_2_mc) {
                    if(canvas.activeTool is BrushTool) {
                        _fillAlpha = e.value;
                        BrushTool(canvas.activeTool).alpha = e.value;
                    } else if (canvas.activeTool is LineTool) {
                        _strokeAlpha = e.value;
                        LineTool(canvas.activeTool).alpha = e.value;
                    } else if (canvas.activeTool is ShapeTool) {
                        _strokeAlpha = e.value;
                        ShapeTool(canvas.activeTool).strokeAlpha = e.value;
                } else if(e.currentTarget == slider_3_mc) {
                    if(canvas.activeTool is BrushTool) {
                        _brushBlur = e.value;
                        BrushTool(canvas.activeTool).blur = e.value;
                    } else if(canvas.activeTool is ShapeTool) {
                        _fillAlpha = e.value;
                        ShapeTool(canvas.activeTool).fillAlpha = e.value;
                Method    : setActiveTool()
                Purpose    : This method sets the program to use a new tool.
                Params    : toolButton -- One of the Tool Buttons.
            private function setActiveTool(toolButton:ItemButton):void {
                // deselect all button to start
                brush_tool_mc.selected = false;
                eraser_tool_mc.selected = false;
                line_tool_mc.selected = false;
                rectangle_tool_mc.selected = false;
                oval_tool_mc.selected = false;
                selection_tool_mc.selected = false;
                fillbucket_tool_mc.selected = false;
                text_tool_mc.selected = false;
                // show combo box
                combo_label_txt.visible = true;
                combo_list.visible = true;
                combo_list.x = _orginalComboBoxItemsPos.comboBox.x;
                combo_list.y = _orginalComboBoxItemsPos.comboBox.y;
                combo_label_txt.x = _orginalComboBoxItemsPos.comboBoxLabel.x;
                combo_label_txt.y = _orginalComboBoxItemsPos.comboBoxLabel.y;
                // set slider
                slider_mc.minimum = 2;
                slider_mc.maximum = 40;
                // enable all slider ui
                slider_mc.visible = true;
                slider_label_txt.visible = true;
                slider_2_label_txt.visible = true;
                slider_2_mc.visible = true;
                slider_3_label_txt.visible = true;
                slider_3_mc.visible = true;
                slider_2_label_txt.alpha = 1;
                // make sure both color pickers are enabled at this point.
                // let each tool block decide to turn them off.
                fill_color_mc.enabled = true;
                stroke_color_mc.enabled = true;
                // brush tool selected
                if(toolButton == brush_tool_mc) {
                    // set selected tool state
                    brush_tool_mc.selected = true;
                    // config color pickers
                    stroke_color_mc.enabled = false;
                    // set brush shape list
                    combo_label_txt.text = "Brush Shapes";
                    combo_list.dataProvider = _brushShapes;
                    combo_list.selectedIndex = _brushShapeIndex;
                    // config and set brush tool as active tool
                    _brush.color = fill_color_mc.selectedColor;
                    _brush.alpha = _fillAlpha;
                    _brush.blur = _brushBlur;
                    _brush.size = _brushSize;
                    _brush.type = combo_list.selectedItem.data;
                    canvas.activeTool = _brush;
                    // update slider
                    slider_label_txt.text = "Brush Size";
                    slider_mc.value = _brush.size;
                    slider_2_label_txt.text = "Brush Alpha";
                    slider_2_label_txt.alpha = 1;
                    slider_2_mc.enabled = true;
                    slider_2_mc.snapInterval = .1;
                    slider_2_mc.value = _brush.alpha;
                    slider_3_label_txt.text = "Brush Blur";
                    slider_3_label_txt.visible = true;
                    slider_3_label_txt.alpha = 1;
                    slider_3_mc.visible = true;
                    slider_3_mc.snapInterval = 1;
                    slider_3_mc.enabled = true;
                    slider_3_mc.minimum = 0;
                    slider_3_mc.maximum = 20;
                    slider_3_mc.value = _brush.blur;
                // eraser tool selected
                } else if(toolButton == eraser_tool_mc) {
                    // set selected tool state
                    eraser_tool_mc.selected = true;
                    // config color picker
                    fill_color_mc.enabled = false;
                    stroke_color_mc.enabled = false;
                    // set brush shape list
                    combo_label_txt.text = "Brush Shapes";
                    combo_list.dataProvider = _brushShapes;
                    combo_list.selectedIndex = _brushShapeIndex;
                    // config and set eraser tool as active tool
                    _eraser.color = fill_color_mc.selectedColor;
                    _brush.alpha = 1;
                    _brush.blur = _brushBlur;
                    _eraser.size = _brushSize;
                    _eraser.type = combo_list.selectedItem.data;
                    canvas.activeTool = _eraser;
                    // update slider
                    slider_label_txt.text = "Brush Size";
                    slider_mc.value = _eraser.size;
                    slider_2_label_txt.text = "Brush Alpha";
                    slider_2_label_txt.alpha = .5;
                    slider_2_mc.enabled = false;
                    slider_2_mc.snapInterval = .1;
                    slider_2_mc.value = _eraser.alpha;
                    slider_3_label_txt.text = "Brush Blur";
                    slider_3_label_txt.visible = true;
                    slider_3_label_txt.alpha = .5;
                    slider_3_mc.visible = true;
                    slider_3_mc.minimum = 0;
                    slider_3_mc.maximum = 20;
                    slider_3_mc.enabled = false;
                    slider_3_mc.value = _eraser.blur;
                // line tool
                } else if(toolButton == line_tool_mc) {
                    // set selected tool state
                    line_tool_mc.selected = true;
                    // config color picker
                    fill_color_mc.enabled = false;
                    // set line style list
                    combo_label_txt.text = "Line Style";
                    combo_list.dataProvider = _lineStyles;
                    combo_list.selectedIndex = _lineStyleIndex;
                    combo_label_txt.x = slider_3_label_txt.x + 8;
                    combo_list.x = slider_3_mc.x;
                    // config and set line tool as active tool
                    _line.color = stroke_color_mc.selectedColor;
                    _line.alpha = _strokeAlpha;
                    _line.type = combo_list.selectedItem.data;
                    canvas.activeTool = _line;
                    // update slider
                    slider_label_txt.text = "Stroke Size";
                    slider_mc.value = _line.lineWidth;
                    slider_2_label_txt.text = "Line Alpha";
                    slider_2_mc.enabled = true;
                    slider_2_mc.snapInterval = .1;
                    slider_2_mc.value = _line.alpha;
                    slider_3_label_txt.visible = false;
                    slider_3_mc.visible = false;
                // rectangle tool
                } else if(toolButton == rectangle_tool_mc) {
                    // set selected tool state
                    rectangle_tool_mc.selected = true;
                    // config and set shape tool as active tool
                    _shape.strokeColor = stroke_color_mc.selectedColor;
                    _shape.fillColor = fill_color_mc.selectedColor;
                    _shape.strokeAlpha = _strokeAlpha;
                    _shape.fillAlpha = _fillAlpha;
                    _shape.type = ShapeType.RECTANGLE;
                    canvas.activeTool = _shape;
                    // set slide value
                    slider_label_txt.text = "Stroke Size";
                    slider_mc.value = _shape.strokeWidth;
                    slider_2_label_txt.text = "Stroke Alpha";
                    slider_2_label_txt.alpha = 1;
                    slider_2_mc.enabled = true;
                    slider_2_mc.snapInterval = .1;
                    slider_2_mc.value = _shape.strokeAlpha;
                    slider_3_label_txt.text = "Fill Alpha";
                    slider_3_label_txt.visible = true;
                    slider_3_label_txt.alpha = 1;
                    slider_3_mc.visible = true;
                    slider_3_mc.enabled = true;
                    slider_3_mc.minimum = 0;
                    slider_3_mc.maximum = 1;
                    slider_3_mc.snapInterval = .1;
                    slider_3_mc.value = _shape.fillAlpha;
                    // hide combo box
                    combo_label_txt.visible = false;
                    combo_list.visible = false;
                // oval tool
                } else if(toolButton == oval_tool_mc) {
                    // set selected tool state
                    oval_tool_mc.selected = true;
                    // config and set shape tool as active tool
                    _shape.strokeColor = stroke_color_mc.selectedColor;
                    _shape.fillColor = fill_color_mc.selectedColor;
                    _shape.strokeAlpha = _strokeAlpha;
                    _shape.fillAlpha = _fillAlpha;
                    _shape.type = ShapeType.OVAL;
                    canvas.activeTool = _shape;
                    // update slider
                    slider_label_txt.text = "Stroke Size";
                    slider_mc.value = _shape.strokeWidth;
                    slider_2_label_txt.text = "Stroke Alpha";
                    slider_2_label_txt.alpha = 1;
                    slider_2_mc.enabled = true;
                    slider_2_mc.snapInterval = .1;
                    slider_2_mc.value = _shape.strokeAlpha;
                    slider_3_label_txt.text = "Fill Alpha";
                    slider_3_label_txt.visible = true;
                    slider_3_label_txt.alpha = 1;
                    slider_3_mc.visible = true;
                    slider_3_mc.enabled = true;
                    slider_3_mc.minimum = 0;
                    slider_3_mc.maximum = 1;
                    slider_3_mc.snapInterval = .1;
                    slider_3_mc.value = _shape.fillAlpha;
                    // hide combo box
                    combo_label_txt.visible = false;
                    combo_list.visible = false;
                // text tool selected
                } else if (toolButton == text_tool_mc || toolButton == selection_tool_mc) {
                    // disable stroke color picker
                    stroke_color_mc.enabled = false;
                    // ui for text
                    slider_label_txt.text = "Text Size";
                    // set font style list
                    combo_label_txt.text = "Font";
                    combo_list.dataProvider = _fontList;
                    combo_list.selectedIndex = _fontIndex;
                    // turn off ui not needed for text tool
                    slider_2_label_txt.visible = false;
                    slider_2_mc.visible = false;
                    slider_3_label_txt.visible = false;
                    slider_3_mc.visible = false;
                    combo_label_txt.x = slider_2_label_txt.x + 8;
                    combo_list.x = slider_2_mc.x;
                    slider_mc.minimum = 10;
                    slider_mc.maximum = 44;
                    slider_mc.value = Number(_textTool.textSettings.textFormat.size);
                    if (toolButton == selection_tool_mc) {
                        selection_tool_mc.selected = true;
                        // set active tool
                        canvas.activeTool = _selectionTool;
                    } else {
                        text_tool_mc.selected = true;
                        var font:Font = Font(combo_list.selectedItem.data);
                        var fmt:TextFormat = new TextFormat();
                        fmt.size = slider_mc.value;
                        fmt.color = fill_color_mc.selectedColor;
                        _textTool.textSettings = new TextSettings(font, fmt);
                        // set active tool
                        canvas.activeTool = _textTool;
                // fill bucket tool selected
                } else if (toolButton == fillbucket_tool_mc) {
                    // turn off ui not needed for fill bucket tool
                    slider_mc.visible = false;
                    slider_label_txt.visible = false;
                    slider_2_label_txt.visible = false;
                    slider_2_mc.visible = false;
                    slider_3_label_txt.visible = false;
                    slider_3_mc.visible = false;
                    combo_label_txt.visible = false;
                    combo_list.visible = false;
                    // turn off stroke color picker
                    this.stroke_color_mc.enabled = false;
                    this._fillBucketTool.fillColor = fill_color_mc.selectedColor;
                    fillbucket_tool_mc.selected = true;
                    // set active tool
                    canvas.activeTool = _fillBucketTool;
                Method    : toolHandler()
                Purpose    : This method will handle switching between brush and eraser
                          tools.  The two tool buttons call this method on click.
                Params    : e -- Mouse Event object.
            private function toolHandler(e:MouseEvent):void {
                setActiveTool(ItemButton(e.currentTarget));
                Method    : comboEventHandler()
                Purpose    : This method will handle the button events for the different
                          Combo box in the UI.
                Params    : e -- Mouse Event object.
            private function comboEventHandler(e:Event):void {
                var font:Font;
                var fmt:TextFormat;
                var ts:TextSettings;
                if(canvas.activeTool is BrushTool) {
                    // store brush shape index
                    _brushShapeIndex = ComboBox(e.currentTarget).selectedIndex;
                    setSelectedBrushShape(ComboBox(e.currentTarget).selectedItem.data);
                } else if(canvas.activeTool is LineTool) {
                    // store line style index
                    _lineStyleIndex = ComboBox(e.currentTarget).selectedIndex;
                    setSelectedLineStyle(ComboBox(e.currentTarget).selectedItem.data);
                } else if (canvas.activeTool is TextTool) {
                    // update font for text tool
                    font = Font(combo_list.selectedItem.data);
                    TextTool(canvas.activeTool).textSettings.font = font;
                    // update font index
                    _fontIndex = combo_list.selectedIndex;
                    // update font for any selected text
                    if (_objectManager.areObjectsSelected()) {
                        fmt = new TextFormat(null, slider_mc.value, fill_color_mc.selectedColor);
                        ts = new TextSettings(font, fmt);
                        _objectManager.changeSettingsForSelectedObjects(ts);
                } else if (canvas.activeTool is SelectionTool) {
                    font = Font(combo_list.selectedItem.data);
                    fmt = new TextFormat(null, slider_mc.value, fill_color_mc.selectedColor);
                    ts = new TextSettings(font, fmt);
                    // update font index
                    _fontIndex = combo_list.selectedIndex;
                    // update text tool
                    _textTool.textSettings = ts;
                    // update font for any selected text
                    if (_objectManager.areObjectsSelected()) {
                        _objectManager.changeSettingsForSelectedObjects(ts);
                Method    : setSelectedLineStyle()
                Purpose    : This method will update the active line with a new line
                          type.
                Params    : localType -- Type of Line.
            private function setSelectedLineStyle(localType:String):void {
                // update the Brush object if different type
                if(BitmapTool(canvas.activeTool).type != localType) {
                    BitmapTool(canvas.activeTool).type = localType;       
                Method    : setSelectedBrushShape()
                Purpose    : This method will update the active brush with a new brush
                          type.
                Params    : localType -- Type of Brush.
            private function setSelectedBrushShape(localType:String):void {
                // update the Brush object if different type
                if(BitmapTool(canvas.activeTool).type != localType) {
                    BitmapTool(canvas.activeTool).type = localType;
                Method    : scrollHandler()
                Purpose    : This method handles the event from the mouse scroll wheel.
                Params    : e -- MouseEvent object
            public function scrollHandler(e:MouseEvent):void {
                // calculate and set zoom of canvas
                canvas.zoom += (e.delta/3) * 1;
                // sync slider to new zoom value.
                zoom_slider_mc.value = canvas.zoom;
                // if canvas is zoomed in then display message about dragging canvas around.
                if(canvas.zoom  > 1) {
                    click_message_txt.alpha = 1;
                } else {
                    click_message_txt.alpha = 0;
                Method    : keyHandler()
                Purpose    : This method handle the keyboard shortcut to drag allow
                          the user to drag the canvas with their mouse.
                Params    : e -- KeyboardEvent object
            public function keyHandler(e:KeyboardEvent):void {
                if(!_objectManager.areObjectsSelected()) {
                    if(e.keyCode == Keyboard.SPACE) {
                        if(e.type == KeyboardEvent.KEY_UP) {
                            canvas.mouseDrag = false;
                        } else if(e.type == KeyboardEvent.KEY_DOWN) {
                            canvas.mouseDrag = true;
      

    This might be outdated since the discount is applied to the access portion and accessories only now.
    Verizon Corporate Discount List - HowardForums Wiki
    Verizon Employee Discount List for 2015

  • Generating a PDF of what the user sees, and sending it as a binary stream to the server

    Hi All,
    On the final page of our Flex app, we allow the user to print out a copy of everything they've entered for their own records.
    I'm wondering if there is a way for me, programmatically, to generate a PDF document that is the same as their printout (I pass a particular container to the "print" button I've got for the user), and send those bytes back to the server.  We can store this PDF along with all the rest of their data, and it would be useful as a "snapshot" of exactly what the user saw when they submitted their application.
    I'm looking into Flex PDF generation, but so far haven't gotten this figured out.  I thought some folks here might be able to point me in the right direction.
    Thanks!
      -Josh

    Here is how you can take a snapshot.
    import mx.graphics.ImageSnapshot;
    import mx.graphics.codec.IImageEncoder;
    import mx.graphics.codec.PNGEncoder;
    import mx.utils.Base64Encoder;
    private function uploadImage(rSource:IBitmapDrawable):void
                        var tBitmapData:BitmapData = ImageSnapshot.captureBitmapData(rSource);
                        var tEnc:IImageEncoder = new PNGEncoder();
                        var tBA:ByteArray = tEnc.encode(tBitmapData);
                        var tB64:Base64Encoder = new Base64Encoder();
                        tB64.encodeBytes(tBA);
                        // send tB64.toString() using POST to the server to save the image.
    // call
    uploadImage(this) // where parameter is an object to get the snapshot of. Can be anything including Application. ("this" in my case).

  • Flash Builder 4.5 SOAP call for images using Base64 Encoding

    I am trying to load some image meta data in a flash builder mobile application by making a SOAP call to .Net service. I am able to test the web service successfully using a .Net console application. However when I make the call from flash builder mobile client I get a null result. What am I doing wrong? I am using SOAP 1.1 ByteArray didn't work for Flash builder. So converted the ByteArray to Base64 format and tried to obtain result that way. Both ways worked from a .Net Client but not working from Flash mobile.
    Here is the code
    <fx:Script>
            <![CDATA[          
                import mx.graphics.ImageSnapshot;
                import mx.graphics.codec.JPEGEncoder;
                import mx.graphics.codec.PNGEncoder;
                import mx.rpc.AsyncToken;
                import mx.utils.Base64Encoder;         
                import services.exifimagemetadata1.ExifImageMetaData1;         
                import spark.components.Image;     
                public var metaData:ExifImageMetaData1 = new ExifImageMetaData1();         
                public var imageBytes:ByteArray = new ByteArray();
                public var gpsData:String;
        private function getBase64EncodedImage():String
                    var myEncoder:Base64Encoder = new Base64Encoder();
                    myEncoder.encodeBytes(getImageBytes());            
                    var image64BitText:String = myEncoder.toString();                          
                    return image64BitText;
        public function GetMetaDataFromExif():void{
                    var imageToken:AsyncToken = metaData.GetExifBase64Data(getBase64EncodedImage());               
                    gpsData = imageToken.result.toString();
                    metaResult.text = gpsData;
        protected function GetImageMetaDataFromExif(event:MouseEvent):void
                    GetMetaDataFromExif();         
            ]]>
        </fx:Script>
    <s:layout>
            <s:VerticalLayout>         
            </s:VerticalLayout>
        </s:layout>
        <s:HGroup>
            <s:Image id="test" width="130" height="140" source="@Embed(source='assets/p1000106.jpg')"/>
        </s:HGroup>
        <s:HGroup>
        <s:Label width="100" height="140" backgroundColor="Blue" click="GetImageMetaDataFromExif(event)">
            <s:text/>
        </s:Label>
        </s:HGroup>
        <s:HGroup>
            <s:Label id="metaResult" width="200" height="140" backgroundColor="yellow"/>           
        </s:HGroup>

    Hello everyone -
    Since I last posted an interesting update happened. I tested my  Flex application again, it is calling a Jetty Server that returns a JSON object, in different BROWSERS.  I disabled HTTPS for now, and the crossdomain.xml policy file is wide open for testing (ie. allowing every request to return data). So the app accessing the data using HTTP only. Browsers  -  IE, Opera, Firefox and Chrome. Each browser contained the SAME application, revision of the Flash Player (10.3.183.10 debugger for firefox, chrome, opera, safari PC; 11.0.1.129 consumer version in IE9,) take a look at the screen shot (safari not shown although the result was the same as IE and chrome)
    Note that Opera and Firefox returned successful values (i.e. successful JSON objects) using the same code generated from the Data Services Wizard. Chrome, IE and, Safari failed with an Internal error. So I am left wondering - WHY? Is it something with the Flash Player? the Browsers?  the Flex SDK? Any thoughts are appreciated. Again, the code is found in the original thread above.

  • Can  i build simple encoder like gzip,- png-, jpeg- or bmp-encoder?

    Hello dear people,
    can i ask about unknown photo- or texture-type?
    TGA File will show into flash-player?
    I know any encoders...
    Example: Encoders:
    For jpeg, png encoder:
    https://github.com/mikechambers/as3corelib/blob/master/src/com/adobe/images/PNGEncoder.as
    For gzip or zip encoder:
    http://code.google.com/p/ascompress/source/browse/trunk/src/com/probertson/utils/GZIPEncod er.as?r=9
    any suggestions encoder for unknown file types?
    If you like openning or viewing file like this OpenOffice Writer like PDF Viewer?
    Can i build tga Encoder for tga, tif and psd file types?
    How do i know hex or binary from current file type?`
    I know becasue encoder for compress like gzip.works nice.
    How do i multi file tree when one or  more files were compressed. But i have been found - same site is down
    Question:
    Why do we need "Encoder" for flash player?
    Do you think because encoder supports complety?
    Thanks

    Nancy O. wrote:
    An image is just an image.  You need HTML or JavaScript code to make it into a hyperlink. 
         <a href="http://example.com"><img src="your_image.jpg"></a>
    Unless the site you're uploading to is willing to wrap your image inside HTML code like the example above or JavaScript there is no way to make the image file link to anything on its own.
    Nancy O.
    But how is it that a pdf file is able to contain a hyperlink within the image and it takes me to my website?  Where on the image.gif, etc., do I attach the code you've posted?  The website I'm wanting to upload the image to, only allows the files with extensions I've already indicated in my op.   Thanx for your reply and help.   -KD

  • Java.lang.NullPointerException.... please help.

    I have been trying to figure out what is wrong with my code, but I have not had any luck. For this program, I used a package called PNGEncoder located here
    http://catcode.com/pngencoder/
    There is a sample code that I tried to follow.
    My code is as follows
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.util.*;
    import java.io.*;
    import com.keypoint.*;
    public class TryShapes extends Frame{
         private int width;
         private int height;
         Image myImage = null;
         private String fileName = "";
         //private int filter = 0;
         //private int compressionLevel = 1;
         //boolean encodeAlpha;
         // Main entry point
    public static void main(String[] args) {
              TryShapes tryShapes =new TryShapes(args[0]);
         public TryShapes(String fileName) {
              System.out.println("This program saves image into file internally.");
              this.fileName = fileName;
              processDrawingFile();
              saveImage();
    private void processDrawingFile(){
         String Instr = null;
    BufferedReader in;
    String fileLocation = "c:\\Drawing files" + File.separator + fileName;
    System.out.println("in start of process file");
    int x, y, r, recWidth, recHeight, x2, y2;     
    // read in file contents
    try{
    in = new BufferedReader(new FileReader(fileLocation));
    //System.out.println("fileLocation");
    Instr = in.readLine(); // the first line of files are titles, skip these
    System.out.println(Instr);
    Instr = in.readLine(); // this is the first line of data (the width & height of bitmap)
    System.out.println(Instr);
    StringTokenizer st = new StringTokenizer(Instr, "\t");
    String s = st.nextToken();
    this.width = Integer.parseInt(s);
    String s2 = st.nextToken();
              this.height = Integer.parseInt(s2);
              System.out.println("width is " + width + " & height is " + height);
              myImage =createImage(width, height);
              System.out.println("after createImage");
    Graphics g;
    g = myImage.getGraphics();
    System.out.println("just after myImage is set to getGraphics");
    while(Instr != null){                 
         Instr = in.readLine(); // read all subsequent lines (elements of the drawing)
         System.out.println(Instr);
    .... and so forth... I used printlines to determine where the program broke and it appears to stop printing after myImage.getGraphics()
    you're help would be much appreciated

    how do i determine if the createImage is not doing what it is suppose to? I'm pretty sure I declared it correctly... java api has
    public Image createImage(int width,
    int height)Creates an off-screen drawable image to be used for double buffering.
    Parameters:
    width - the specified width.
    height - the specified height.
    Returns:
    an off-screen drawable image, which can be used for double buffering.
    and the arguments are integers... what else could be wrong?

Maybe you are looking for

  • Power Outage During Time Machine Backup...

    Hey everyone, I have a 1TB LaCie Big Disk+ and my someone threw the switch on the socket breaker for my room while time machine was backing up. The computer no longer can recognize the hard drive. It was partitioned and I can read it when I go to win

  • Mac OS 10.10 Yosemite and HP Printer Support

    With the release of the New Mac OS 10.10 Yosemite, HP has provided a list of supported HP Printers, and an FAQ with Yosemite related content. HP Supported Printers in OS 10.10 Yosemite and FAQ If you already have an HP Printer installed and working o

  • When starting InDesignCS2 received new error message -- InDesign is missing required system fonts or

    We are not able to start Indesign CS2 without getting the error message: <<InDesign is missing required system fonts or CMap files. Please reinstall InDesign.>> This is on WinXP.<br /><br />Recently I installed Creative Suite CS4. It took almost a da

  • Sequence frame size/black border

    I created several sequences in Final Cut Pro 4, which all seem to have the same settings, but some of them have a black border around the picture and a smaller picture size. When I export a Quick Time Movie of the sequence, the boarder still exists i

  • 2nd Gen iPod Nano - Impossible Restore

    I recently bought a used 4gb 2g nano and had it working fine. Forgettiing that it needed itunes 7 to work, I formatted it in hope it would would with itunes 6. Remembering this, I had to install itunes 7, bringing me to my problem... When I try to re