Want to make a paint bucket and open feature

I am making this drawing application that so far contains a pencil tool, eraser, text tool, clear tool, and even save image feature. There are a few more features that I would like to add, including a paint bucket tool and a open image feature, but I am not sure exactly how to code them. Here is my code for the whole program:
package
import PNGEncoder;
import flash.display.MovieClip;
import flash.display.Shape;
import flash.display.DisplayObject;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldType;
import flash.text.TextFieldAutoSize;
import flash.display.BitmapData;
import flash.geom.ColorTransform;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.utils.ByteArray;
import flash.net.FileReference;
public class Main extends MovieClip
/* Variables */
/* Pencil Tool shape, everything drawed with this tool and eraser is stored inside board.pencilDraw */
var pencilDraw:Shape = new Shape();
/* Text format */
var textformat:TextFormat = new TextFormat();
/* Colors */
var colorsBmd:BitmapData;
var pixelValue:uint;
var activeColor:uint = 0x000000;
/* Save dialog instance */
var saveDialog:SaveDialog;
/* Active var, to check wich tool is active */
var active:String;
/* Shape size color */
var ct:ColorTransform = new ColorTransform();
public function Main():void
textformat.font = "Arial";
textformat.bold = true;
textformat.size = 24;
convertToBMD();
addListeners();
/* Hide tools highlights */
pencil.visible = false;
hideTools(eraser, txt);
/* Pencil Tool */
private function PencilTool(e:MouseEvent):void
/* Quit active tool */
quitActiveTool();
/* Set to Active */
active = "Pencil";
/* Listeners */
board.addEventListener(MouseEvent.MOUSE_DOWN, startPencilTool);
board.addEventListener(MouseEvent.MOUSE_UP, stopPencilTool);
/* Highlight */
highlightTool(pencil);
hideTools(eraser, txt);
ct.color = activeColor;
shapeSize.transform.colorTransform = ct;
private function startPencilTool(e:MouseEvent):void
pencilDraw = new Shape();
board.addChild(pencilDraw);
pencilDraw.graphics.moveTo(mouseX, mouseY);
pencilDraw.graphics.lineStyle(shapeSize.width, activeColor);
board.addEventListener(MouseEvent.MOUSE_MOVE, drawPencilTool);
private function drawPencilTool(e:MouseEvent):void
pencilDraw.graphics.lineTo(mouseX, mouseY);
private function stopPencilTool(e:MouseEvent):void
board.removeEventListener(MouseEvent.MOUSE_MOVE, drawPencilTool);
/* Eraser Tool */
private function EraserTool(e:MouseEvent):void
/* Quit active tool */
quitActiveTool();
/* Set to Active */
active = "Eraser";
/* Listeners */
board.addEventListener(MouseEvent.MOUSE_DOWN, startEraserTool);
board.addEventListener(MouseEvent.MOUSE_UP, stopEraserTool);
/* Highlight */
highlightTool(eraser);
hideTools(pencil, txt);
ct.color = 0x000000;
shapeSize.transform.colorTransform = ct;
private function startEraserTool(e:MouseEvent):void
pencilDraw = new Shape();
board.addChild(pencilDraw);
pencilDraw.graphics.moveTo(mouseX, mouseY);
pencilDraw.graphics.lineStyle(shapeSize.width, 0xFFFFFF);
board.addEventListener(MouseEvent.MOUSE_MOVE, drawEraserTool);
private function drawEraserTool(e:MouseEvent):void
pencilDraw.graphics.lineTo(mouseX, mouseY);
function stopEraserTool(e:MouseEvent):void
board.removeEventListener(MouseEvent.MOUSE_MOVE, drawEraserTool);
/* Text Tool */
private function TextTool(e:MouseEvent):void
/* Quit active tool */
quitActiveTool();
/* Set to Active */
active = "Text";
/* Listener */
board.addEventListener(MouseEvent.MOUSE_UP, writeText);
/* Highlight */
highlightTool(txt);
hideTools(pencil, eraser);
private function writeText(e:MouseEvent):void
var textfield = new TextField();
textfield.type = TextFieldType.INPUT;
textfield.autoSize = TextFieldAutoSize.LEFT;
textfield.selectable = false;
textfield.defaultTextFormat = textformat;
textfield.textColor = activeColor;
textfield.x = mouseX;
textfield.y = mouseY;
stage.focus = textfield;
board.addChild(textfield);
/* Save */
private function export():void
var bmd:BitmapData = new BitmapData(600, 290);
bmd.draw(board);
var ba:ByteArray = PNGEncoder.encode(bmd);
var file:FileReference = new FileReference();
file.addEventListener(Event.COMPLETE, saveSuccessful);
file.save(ba, "ballin.png");
private function saveSuccessful(e:Event):void
saveDialog = new SaveDialog();
addChild(saveDialog);
saveDialog.closeBtn.addEventListener(MouseEvent.MOUSE_UP, closeSaveDialog);
private function closeSaveDialog(e:MouseEvent):void
removeChild(saveDialog);
private function save(e:MouseEvent):void
export();
/* Clear Tool */
private function clearBoard(e:MouseEvent):void
/* Create a blank rectangle on top of everything but board */
var blank:Shape = new Shape();
blank.graphics.beginFill(0xFFFFFF);
blank.graphics.drawRect(0, 0, board.width, board.height);
blank.graphics.endFill();
board.addChild(blank);
/* Default colors function */
private function convertToBMD():void
colorsBmd = new BitmapData(colors.width,colors.height);
colorsBmd.draw(colors);
private function chooseColor(e:MouseEvent):void
pixelValue = colorsBmd.getPixel(colors.mouseX,colors.mouseY);
activeColor = pixelValue;//uint can be RGB!
ct.color = activeColor;
shapeSize.transform.colorTransform = ct;
/* Quit active function */
private function quitActiveTool():void
switch (active)
case "Pencil" :
board.removeEventListener(MouseEvent.MOUSE_DOWN, startPencilTool);
board.removeEventListener(MouseEvent.MOUSE_UP, stopPencilTool);
case "Eraser" :
board.removeEventListener(MouseEvent.MOUSE_DOWN, startEraserTool);
board.removeEventListener(MouseEvent.MOUSE_UP, stopEraserTool);
case "Text" :
board.removeEventListener(MouseEvent.MOUSE_UP, writeText);
default :
/* Highlight active Tool */
private function highlightTool(tool:DisplayObject):void
tool.visible=true;
private function hideTools(tool1:DisplayObject, tool2:DisplayObject):void
tool1.visible=false;
tool2.visible=false;
/* Change shape size */
private function changeShapeSize(e:MouseEvent):void
if (shapeSize.width >= 50)
shapeSize.width = 1;
shapeSize.height = 1;
/* TextFormat */
textformat.size = 16;
else
shapeSize.width += 5;
shapeSize.height=shapeSize.width;
/* TextFormat */
textformat.size+=5;
private function addListeners():void
pencilTool.addEventListener(MouseEvent.MOUSE_UP, PencilTool);
eraserTool.addEventListener(MouseEvent.MOUSE_UP, EraserTool);
textTool.addEventListener(MouseEvent.MOUSE_UP, TextTool);
saveButton.addEventListener(MouseEvent.MOUSE_UP, save);
clearTool.addEventListener(MouseEvent.MOUSE_UP, clearBoard);
colors.addEventListener(MouseEvent.MOUSE_UP, chooseColor);
sizePanel.addEventListener(MouseEvent.MOUSE_UP, changeShapeSize);
shapeSize.addEventListener(MouseEvent.MOUSE_UP, changeShapeSize);
Any ideas on how to code these features?

any1?

Similar Messages

  • I use Adobe Premiere Elements 11. I want to make a Credit Roll and start off screen and stop with the credit remaining still in the middle of the screen. I know this can be done with CS6. Can this be done in Elements 11? Does Elements 12 or 13 have these

    I use Adobe Premiere Elements 11. I want to make a Credit Roll and start off screen and stop with the credit remaining still in the middle of the screen. I know this can be done with CS6. Can this be done in Elements 11? Does Elements 12 or 13 have these options for Credit Roll.

    stevel
    Please read my work on this topic which involves Premiere Elements Preroll and Postroll settings.
    ATR Premiere Elements Troubleshooting: PE: Preroll and Postroll Options Interpreted
    Especially the section relating to Titler, Roll and Crawl Titles.
    Please let us know if that worked for you.
    Thank you.
    ATR

  • Photoshop in Adobe RGB 16 bit don't fill a layer with paint bucket and a color 35.40.35.100.

    I create a new file in RGB profile Adobe RGB 16bit
    take the paint bucket and fill the layer with a color created by selector with the following parameters 35.40.35.100 CMYK and RGB corresponds to 24.20.18 the result is a full level of color 76.73.63.9 but in RGB corresponds to 24.20.18 because the values in cmyk not match ??

    Could you please post screenshots (with the pertinent Panels visible) to illustrate the issue?
    Are you not aware that you cannot reliably define a CMYK color in RGB because the transformation is performed through the Profile Connection Space (Lab) and depends on the involved Color Spaces/ICC profiles (edited) and the Color Settings?

  • I want to take image from Photos and open in Photoshop.

    I want to take image from Photos and open in Photoshop.  In iPhoto I was able to drag it into PS icon, but now can't do that.

    File -> Export
    There is a feature called extensions in Photos that allows developers to write a hook so that photoshop and similar apps might work with Photos, but none have doe that yet,

  • Missing Paint Bucket and Paint Drop

    Good morning,
    I seem to be missing my paint bucket and paint drop.  They are not showing on the icon tool bar.  I have checked in tool icon drop down menu (top left).  I have checked the gradient drop down menu (reached by pressing G when I was in a new document).  Checked in all the option menus Image/layer/type etc and have drawn a blank.  Can anyone help?

    Right-click on the Gradient to see the choices. Or keep pressing Shift+G a few times on the keyboard to tab.

  • I want to make a folder "A" and save to disk (appendable), then as and when required I wish to append to that folder files "B" and later on files "C" and so on.  What would be the way to do this.

    I want to make a folder "A" and save to disk(appendable), then as and when required I want to append files "B" and "C" and so on to that folder, what would be the way to do this.

    It's not clear how what you're describing is different from the way all folders work.

  • I forgot the answer to the security questions and i forgot the email i put there to resend the link so i can change it. i want to close my apple ID and open a new one with the same email could i?

    i forgot the answer to the security questions and i forgot the email i put there to resend the link so i can change it. i want to close my apple ID and open a new one with the same email could i?

    i live in saudi arabia and i tried calling them and letting them call me but they said that it is unable to my country. ***** i don't know what to do!

  • Live paint bucket and eyedropper

    Right; I've got my fill color set up in the toolbar using the eye dropper.
    Now I activate the 'live paint bucket' tool, and the fill color vanishes.
    So I hit 'i' for the eyedropper again and lose the bucket tool.
    The color picker the doesn't have eye dropper ability like big brother PS so how the f*** am I supposed to get my bucket's color? (other than fill up my swatches)
    At the moment I am sampling in Photoshop and copying the hexidecimal code.
    12 years in Photoshop, 3 days in illustrator and can't believe this is industry standard.

    DelBoy78 wrote:
    I've found what the alt+eyedropper is all about; shortcut for applying a fill colour to a line. Thanks for that but as the image lower down shows, the areas I want to fill with colour are not built from a single fillable line.
    Eyedropper applies the attributes of the clicked object to the selected object/s as set in its options accessible by double clicking the Eyedropper tool
    Holding Alt while clicking with the Eyedropper (In my version CS5) does the opposite - it applies the attributes from the selected object to the object being clicked.
    Holding Shift while clicking with the Eyedropper applies the color being clicked to the fill or stroke of the selected object/s depending on which (the fill or the stroke) is in front in the color selector found in the Tool box and the Color panel. Pressing the X key on your keyboard, swaps which color, fill or stroke, is in front (focus of your input).
    While using the Live Paint Bucket tool, holding Alt switches temporarily to the Eyedropper tool. However using the Eyedropper to pick colors from a Live Paint group may feel as if it is working differently because it may not be picking the stroke color. This is because internally behind the scene, the Live Paint group is separating the fills as different objects without strokes. Expanding the Live Paint group reveals this.

  • Paint bucket and Pencil color fill problem

    Hi,
    I'm coloring a comic book and I'm having an annoying bug with CS4.
    Say I want to color these bushes:
    I put the color on another layer set to Multiply. Using the Pencil tool (no anti-aliasing), I close all the gaps.
    Then fill it with the Paint bucket (anti-aliasing off, contiguous, sample all layers) using the same color.
    Now say I later decide to change that color; naturally I'll use the Paint bucket.
    This is what happens:
    As you can see the pencil strokes are still there, as if they were a different color, even if they're not!
    But on closer inspection, it turns out the CMYK values are off by 1%. I have no idea why this happens. The tools are all set at the exact same color and opacity.
    Someone posted a thread 9 months ago about this problem but it wasn't solved: http://forums.adobe.com/thread/781035
    He says it also occurs on CS5.
    I can only assume it's a bug. Help?

    I just tried with the pencil set to Multiply, and it happened. And contradicting what I said earlier, the problem happened with Normal as well.
    Well, here's another update: the real culprit seems to be the paint bucket tool. I experimented with color samplers to precisely measure the CMYK values. This is completely bizarre:
    The paint bucket will occasionnally fill with a color that is off by 1% from the intended color. It seems to happen randomly, but more often with darker colors.
    Check this out:
    Sampler 1 is where I closed the gap with the pencil. Sampler 2 is the paint bucket fill.

  • How can I REMOVE the Yahoo! tab from the menu bar? Each time I open Firefox, I get the gialogue box asking if I want to make yahoo the default and each time I respond no and check the do not ask this question again.

    I am tempted to remove Ff4 and revert to 3.X if I cannot fix this problem. The question (statement) has all pertinent details already included

    '''Hello peacefultrev,'''
    I believe from your question you wish to remove the window title-bar, while keeping the menu bar available.
    I have two solutions for you to try. One requires no plugin and the other requires the installation of a plugin.
    '''No plugin option:'''
    This option hides the the window title while also removing the menu bar. The menu bar can then be reactivated and viewed simply by pressing "Alt" which shows the menu bar until you click away from it. To do this:
    # Right click on the tab bar and disable "Menu Bar".
    # Whenever you which to use the menu bar, tap "Alt" on your keyboard.
    # When you click away from the menu bar the windows title will disappear until you tap "Alt" again.
    '''Plugin Option:'''
    You can download this plugin called [https://addons.mozilla.org/en-US/firefox/addon/hide-caption-titlebar-plus-sma/ Hide Caption Titlebar Plus] which can be customized to suit your needs. I cannot provide support on this plugin as I have not used it myself.
    I hope one of these solutions will suit your needs.
    Mattlem

  • I have a mac book pro i want to have another monitor added and open garageband with 2 projects open is this possible.

    I have a mac book pro I want to use 2 monitors and have garageband open with 2 projects is this possible?

    GarageBand can open only one project at a time.  Project are treated differently from audio files; you can have many audio files open in QuickTime or other audio players, but GarageBand will always close the current project when you open a new one.
    If you have the newest GarageBand 10.0 and the previous version, GarageBand '11, version 6.0.5, you can open one project in GarageBand 10.0 and one project in GarageBand '11.
    However, you cannot drag and top between the windows or transfer media. And once a project has been converted to GarageBand 10 format, it can no longer be opened by GarageBand '11.

  • HT1918 What if I want to make a new account, and I don't want to purchase the same product twice?

    I have one a count which works fine, but it won't buy anything from the US store and I can't change my nationality because of my season passes. So I decided to make a new account with the address I have in America, but I would have to buy everything I already did twice. So is there a way I can transfer purchases to my American account?

    No, there isn't. You'll need to continue to use that existing account for updates or to redownload purchased content.
    Note that to set up an account in the US iTunes Store for anything other than free apps, you'll need not only a US mailing address but also a US credit card or prepaid iTunes card.
    Regards.

  • Can I create a simple Drawing App with Crayon, Marker, Paint Bucket and Eraser in Edge?

    I need to create an 'app' that allows user to 'color'/'paint' in simple colorbook pages with a specific color palette or if I can have an expanded color palette great..
    any thots
    I have found the code to do it, but I am not a coder that is why I am investigating Edge...
    Many thanks

    Hi, mark-
    It's going to be hard to do without code in Animate.  Yoshoika Ume-san did a little project in an earlier version of Animate that did it, but it was heavily code centric.
    Thanks,
    -Elaine

  • Loaded photo into iPhoto and wanted to make a movie

    I have 40 images, one song and wanted to make a quicktime movie and post for friends
    Made the movie, 128 mb looks nice. (480x640) now I want to share it with friends. I tried to load it to my .mac public it get to the end uploading and locks up the computer. notthing is running, cant delete it it says its in use.. I did the same thing with Small size 240x180 its still 35mb
    How can I make a movie with a song and share it
    I cant run iDvd or iMovie I'm still on G4 with 1.2 ghz
    myspace has a limit of 100mb and NO option for .mov (quicktime movie)
    help please

    There are a couple of things you can do. One is to resize it during export from iPhoto to 320 x 240, a common size used for posting. Another is to use a video editor like VisualHub to reduce the size down to something more manageable. Possibly reducing the frame rate to 15 from 29 if it's at 29. Quicktime Pro can also resize movie files.
    If you visit the iMovie or Quicktime forum you should find some more knowledgeable users in this area.
    Do you Twango?
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Paint bucket, smudge and other tools missing

    Sorry If I am completely stupid, but the last version I used was 3.0
    Ok big problem I am so frusrated I can barely sit here anymore. I am looking at all my tools on the left hand side. I get to the tools by going to window-> tools out of all the tools, there is no smudge or paint bucket. who knows how many other tools are missing. so i went to help and find and typed in smudge and paint bucket and nothing.
    I googled cs4 paint bucket and smudge and apparently there is such options for cs4. but there are NO icons in the tools. what do i do???

    Oh i see, I hold down option and click blur and it will change to smudge and i hold option and click gradient and it will change it to paint bucket! Wow thank you soooo much! I have no clue why they didn't put that in help. Thanks!!!

Maybe you are looking for

  • Mail files in Mail  1.3.11 vs Mail 2.1.2?

    I recently attempted to import my Mail info from my primary computer running 10.4.11 with Mail 2.1.2 into a computer I plan to use for backup use that is running 10.3.9 and Mail 1.3.11 I used a post I found here in the Discussions on 'Moving Folders

  • Export-Import and Naming convention question

    All, Newbie here. Have a question related to the naming convention for SAP R/3 system and XI manual export/import process. We are currently in the development environment where our R/3 systems are named as D55CLNT400, D56CLNT300 etc (first 3 characte

  • Upload, yes ... but  download ?

    Hello to everybody: I have seen the sample to upload a file from the client browser to middle tier (server). But I would need to download a file (or data from the Form screen) from the form (running in the server) to a disk in the client, the reverse

  • MobileMe Sharing Key Commands?

    Hi, I have a Mac Pro and newly purchased 17" MBP which is my remote editing suite. I have some useful customized keyboard shortcuts which I told my Mac Pro's Logic Studio to backup/sync on Mobile Me. After trying various ways of getting these key com

  • Automatically return to main vi from subi

    I have a main VI and a sub VI. The sub vi front panel is opened when it is called and the main VI is updated. But I need to automatically return to the main VI front panel after running the subvi Attachments: 24-01-2014 main vi.vi ‏121 KB electron vo