How do I create a button in AS3?

Hello Everyone
How do I create a button in action script 3 and handle the click event?
Thanks

Maybe this will help you get started.
import flash.display.Sprite;
import flash.events.Event;
import flash.display.Graphics;
var button:Sprite = new Sprite();  //Sprite to act as the button graphic.
//Set the color of the button graphic
button.graphics.beginFill(0xFFCC00);
//Set the X,Y, Width, and Height of the button graphic
button.graphics.drawRect(10, 10, 200, 60);
button.graphics.endFill(); //Apply the fill
this.addChild(button);  //Add Button Sprite to stage
button.useHandCursor = true;
button.buttonMode = true;
button.mouseChildren = false;
button.addEventListener(MouseEvent.CLICK, buttonClickHandler);
function buttonClickHandler(event:MouseEvent):void
           trace("Button clicked!");

Similar Messages

  • How can i create a button with a dynamic picture?

    How can i create a button with a dynamic picture using
    mcLoader.loadClip
    I did create one with it doesnt seem to be working. It loses
    all its
    functions (eg onPress onRelease)
    Thanks

    I solved thep roblem anyway creating a mc.. then creating
    another MC withing
    the first MC and i change the picture on the second MC. And i
    apply the
    propierities to the first MC , and works
    If i have troubles with mu sistem on the future I will use
    yours!
    Thanks!
    "the fleece" <[email protected]>
    escribi� en el mensaje
    news:e67i88$jlf$[email protected]..
    > the image loading will remove any properties or
    functions the mc had.
    >
    > you need to apply them in the onLoadInit function
    >
    > mclListener.onLoadInit = function(target_mc:MovieClip) {
    > target_mc.onRollOver=blah blah
    > };
    > var image_mcl:MovieClipLoader = new MovieClipLoader();
    > image_mcl.addListener(mclListener);
    > image_mcl.loadClip(blah, blahblah);
    >
    >

  • How do I create a button in a selction screen of the report ??

    how do I create a button in a selction screen of the report ??

    See sample Program :
    REPORT ZLPRWINSPC_TMP .
    tables : mara,
             sscrfields.
    select-options s_matnr for mara-matnr.
    initialization.
    sscrfields-functxt_01 = 'Clear Selection'.
    selection-screen function key 1.
    AT SELECTION-SCREEN.
    case sscrfields-ucomm.
    when 'Clear Selection' or 'FC01'.
    clear s_matnr.
    refresh s_matnr.
    endcase.
    Reward Points if it is helpful
    Thanks
    Seshu

  • In DPS/Indesign for iPad - How can i create a button that once tapped, will pre-populate an email?

    In DPS/Indesign for iPad - How can i create a button that once tapped, will pre-populate an email? like when you tap a recipe in Marth Stewart Every Day Food for example....

    http://forums.adobe.com/message/4190932

  • How can i create a button? t

    i'm new in using flash, how can i create a button and link it in other scene? thanks in advance

    Please re-post the question to the Flash forum at http://forums.adobe.com/community/flash/flash_general.
    Steve

  • How do you create a button to add a new form page to an existing form in Acrobat or Livecycle designer?

    Can someone tell me how to create a button to add a new form page to an existing form in Acrobat or Livecycle designer?

    In Acrobat forms you can use the 'template' object's 'spawn' metod. A Lesson in Templates for Adobe Acrobat by Dave Wrigtht

  • How can I create a button that looks like this?

    Hey everyone,
    I'm trying to create a button in photoshop for a web project I'm working on and I found something similar to what I'm trying to do already being used online. I'm trying to get something similar to the bottom row of buttons in this image:
    The bottom row of buttons uses a gradient overlay effect... but there is a small darker area in the top left corner of each of those images. It looks to be exactly the same in each image... meaning I'm guessing it's not hand drawn with something like the burn tool?
    How would I go about doing something similar? What's the easiest way to reproduce the effect shown above keeping it consistant from button to button?

    One way is using layers.
    Color layer on the botton so changing colors simply change color layer.
    Place all your image effects on the overlying layers.

  • How can i create a button with richText display instead of label

    Hi All,
    I'm trying to create a button that will look exactly as the regular spark button but will have more than one color in his label (Like attached 'buttonPic.jpg')
    I have tried to create a new button skin and new button component that will replace the label text and will to the job, but still it looks like the button original class overides the richText definitions. (Code attached)
    Maybe there is other solution?
    This is my extra code in the MyButtonSkin
         <!-- layer 8: text -->
        <!---
        @copy spark.components.supportClasses.ButtonBase#labelDisplay
        -->
        <s:Label id="labelDisplay"
                 visible="false">
        </s:Label>
        <s:RichText id="exLabelDisplay"
                    color="0x900000"
                    textFlow="{TextConverter.importToFlow(htmlTextAsHTML, TextConverter.TEXT_FIELD_HTML_FORMAT)}"
                    left="7" right="7" top="2" bottom="2">
        </s:RichText>
        <fx:Declarations>
            <fx:String id="htmlTextAsHTML"><![CDATA[<p><b>0</b>+</p>]]></fx:String>
        </fx:Declarations>

    Hi mewk,
    probably it was a catch due to eyes that actually got a bit of sleep
    anyway small test app
    <?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/halo" minWidth="1024" minHeight="768">
    <fx:Script>
    <![CDATA[
    protected function updateBtn_clickHandler(event:MouseEvent):void
    richbtn.label=mytext.text;
    ]]>
    </fx:Script>
    <s:Button id="richbtn" x="69" y="58" width="169" height="83" skinClass="ButtonSkin1" label="&lt;p&gt;hello&lt;/p&gt;&lt;p&gt;goodbye&lt;/p&gt;"/>
    <s:Button x="70" y="333" label="Update rich button" id="updateBtn" click="updateBtn_clickHandler(event)"/>
    <s:TextArea x="69" y="174" id="mytext" text="&lt;p&gt;hello&lt;/p&gt;&lt;p&gt;&lt;b&gt;bold&lt;/b&gt;&lt;/p&gt;"/>
    </s:Application>
    and a skin with minimal change
    <?xml version="1.0" encoding="utf-8"?>
    <s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
                 xmlns:fb="http://ns.adobe.com/flashbuilder/2009" minWidth="21" minHeight="21" alpha.disabled="0.5">
        <fx:Metadata>
            <![CDATA[
            [HostComponent("spark.components.Button")]
            ]]>
        </fx:Metadata>
        <fx:Script fb:purpose="styling">
            <![CDATA[        
    import flashx.textLayout.conversion.TextConverter;
                static private const exclusions:Array = ["labelDisplay"];
    override public function get colorizeExclusions():Array {return exclusions;}
              override protected function initializationComplete():void
                    useBaseColor = true;
                    super.initializationComplete();
    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number) : void
                    var cr:Number = getStyle("cornerRadius");
                    if (cornerRadius != cr)
                        cornerRadius = cr;
                        shadow.radiusX = cornerRadius;
                        fill.radiusX = cornerRadius;
                        lowlight.radiusX = cornerRadius;
                        highlight.radiusX = cornerRadius;
                        border.radiusX = cornerRadius;
                    if (highlightStroke) highlightStroke.radiusX = cornerRadius;
                    super.updateDisplayList(unscaledWidth, unscaledHeight);
                private var cornerRadius:Number = 2;
            ]]>       
        </fx:Script>
        <!-- states -->
        <s:states>
            <s:State name="up" />
            <s:State name="over" />
            <s:State name="down" />
            <s:State name="disabled" />
        </s:states>
        <!-- layer 1: shadow -->
        <s:Rect id="shadow" left="-1" right="-1" top="-1" bottom="-1" radiusX="2">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0x000000"
                                     color.down="0xFFFFFF"
                                     alpha="0.01"
                                     alpha.down="0" />
                    <s:GradientEntry color="0x000000"
                                     color.down="0xFFFFFF"
                                     alpha="0.07"
                                     alpha.down="0.5" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 2: fill -->
        <s:Rect id="fill" left="1" right="1" top="1" bottom="1" radiusX="2">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0xFFFFFF"
                                     color.over="0xBBBDBD"
                                     color.down="0xAAAAAA"
                                     alpha="0.85" />
                    <s:GradientEntry color="0xD8D8D8"
                                     color.over="0x9FA0A1"
                                     color.down="0x929496"
                                     alpha="0.85" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 3: fill lowlight -->
        <s:Rect id="lowlight" left="1" right="1" bottom="1" height="9" radiusX="2">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0x000000" alpha="0.0099" />
                    <s:GradientEntry color="0x000000" alpha="0.0627" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 4: fill highlight -->
        <s:Rect id="highlight" left="1" right="1" top="1" height="9" radiusX="2">
            <s:fill>
                <s:SolidColor color="0xFFFFFF"
                              alpha="0.33"
                              alpha.over="0.22"
                              alpha.down="0.12" />
            </s:fill>
        </s:Rect>
        <!-- layer 5: highlight stroke (all states except down) -->
        <s:Rect id="highlightStroke" left="1" right="1" top="1" bottom="1" radiusX="2" excludeFrom="down">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0xFFFFFF" alpha.over="0.22" />
                    <s:GradientEntry color="0xD8D8D8" alpha.over="0.22" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!-- layer 6: highlight stroke (down state only) -->
        <s:Rect left="1" top="1" bottom="1" width="1" includeIn="down">
            <s:fill>
                <s:SolidColor color="0x000000" alpha="0.07" />
            </s:fill>
        </s:Rect>
        <s:Rect right="1" top="1" bottom="1" width="1" includeIn="down">
            <s:fill>
                <s:SolidColor color="0x000000" alpha="0.07" />
            </s:fill>
        </s:Rect>
        <s:Rect left="2" top="1" right="2" height="1" includeIn="down">
            <s:fill>
                <s:SolidColor color="0x000000" alpha="0.25" />
            </s:fill>
        </s:Rect>
        <s:Rect left="1" top="2" right="1" height="1" includeIn="down">
            <s:fill>
                <s:SolidColor color="0x000000" alpha="0.09" />
            </s:fill>
        </s:Rect>
        <!-- layer 7: border - put on top of the fill so it doesn't disappear when scale is less than 1 -->
        <s:Rect id="border" left="0" right="0" top="0" bottom="0" width="69" height="20" radiusX="2">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0x000000"
                                     alpha="0.5625"
                                     alpha.down="0.6375" />
                    <s:GradientEntry color="0x000000"
                                     alpha="0.75"
                                     alpha.down="0.85" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!-- layer 8: text -->
    <s:RichText id="LabelDisplay"
    color="0x900000"
    textFlow="{TextConverter.importToFlow(hostComponent.label, TextConverter.TEXT_FIELD_HTML_FORMAT)}"
    left="7" right="7" top="2" bottom="2">
    </s:RichText>   
    </s:SparkSkin>

  • Acrobat 9.0 Std - How do I create a button that will show / hide the menu bar?

    In Adobe Acrobat 8, I was able to create a button that would show the menu bar using Link Properties. In version 9.0, the option I used is missing.
    The other view options are there under "Execute a menu item": View > Toolbars > File, Edit, etc.
    Any help would be greatly appreciated - thanks!

    In Adobe Acrobat 8, I was able to create a button that would show the menu bar using Link Properties. In version 9.0, the option I used is missing.
    The other view options are there under "Execute a menu item": View > Toolbars > File, Edit, etc.
    Any help would be greatly appreciated - thanks!

  • How do You create menu buttons that move up and down with a remote?

    I have six menu items that are linked to their proper locations. When I simulated it a Hand moves over the proper choice then when I click there we go.
    But on the DVD simulator you can't navigate. I thought maybe I would bring in one of the templates to use their buttons I can't get my images to replace theirs. Any help appreciated.
    Jerome

    Take a look here to make sure buttons are being set properly
    http://dvdstepbystep.com/buttons07m.php
    And download the movie if you like
    I create a button, then set the text and include highlights
    I then create another button, then set the text and the include highlights
    I then click on the menu and go to the inspector to see colors
    RED Normal
    BLUE Selected
    YELLOW Activated
    In simulater I then use the remote control and CANNOT navigate through the buttons
    I stop Simulator and then use Auto Assign Buttons Now Command, then relaunch Simulator and get the remote control to work
    Make sure to link the button to the track you want to go to.
    I thought the issue is that you cannot navigate the buttons with the remote control? If you only have one button on the screen, it will always be selected (Yellow in your project as described)
    If it is flashing Megenta and nothing happens, it means a target has not been set (or somehow you are targeting the menu again)
    So the only two condiitions you will see is yellow or magenta.

  • How can I create browse button

    Hello,
    I am trying to open a new window that can browse you a file and return a file path.
    Please help me how to create this browse button.
    Hope you can help me soon. Thanks!
    Nongnie
    null

    You may want to look at the file upload bean if you are 6i web deployed? http://otn.oracle.com/sample_code/products/forms/listing.htm#jbpjc

  • How can you create a button master that can be unlocked but where edits to the master will affect all buttons?

    I'm creating a course calendar (January - December) for an organization and courses are repeated several times throughout the year. I've been asked to create this as an interactive pdf rather than as an interactive Indesign document that can be viewed via a browser, so I'm unable to use multi-state objects
    Anyway, I've created button masters for such buttons such as previous page/next page, course index and search on my master pages, so that's all fine and dandy as I don't need to move these elements. The way I have set up the calendar is that you click on the course name (a button) and a popup (also a button) shows up with a course description - I want to be able to move these popups so that they are the general vicinity of the course name button and not just floating about in the centre of the calendar.
    However, because course descriptions or what is offered in the course change frequently and I am expected to keep the calendar up to date, it doesn't seem efficient to have to manually change every description for a course popup that shows up several times throughout the year or even several times on a month. The issue is that even if I create the popups on the master page, as soon as I unlock them on my month pages and move them to where I want them to be...they'll no longer be affected by changes to the master.
    Is there some sort of function like in html/CSS where you can assign a class to a button or something? Or it is something that Indesign isn't capable of and I will just have to do it manually and try to be careful not to miss any courses when they are updated?
    Any help is appreciated!

    While you could create a different screen for each, a better way to do this is via some form of database.  The buttons cause functions to be executed and the functions utilize data resources based on the selections that are established.
    So if you pick a particular character, a variable is a assigned a value that indicates that.  That variable is then utilized to extract the data associated with the character and to build the screen elements related to the options for that character.

  • How can I create a button that performs the function of a keyboard shortcut, specifically print scrn

    I need my presentation users to take a screen shot of a slide within my presentation.  I know that windows 8 has a new function that allows a screen shot to be taken and saved directly to the user's computer and I need a button that can be placed on a slide and perform this function.  The shortcut is (windows key) + (print scrn).  I want to save my userss some time and just have a button perform this task.  Any idea on how I can make this possible? I am using Captivate 7.

    I think Ajit may have misunderstood your need.  The command he told you about triggers the Print command to allow you to print the currently active slide (on a laser or inkjet printer). This does not have the same result as you would get by hitting the PrintScreen button on your keyboard (to take a screencapture and have it saved to the Clipboard for pasting somewhere else).
    You can add a button to your slide and set the PrintScreen key as the shortcut, but this will NOT mean that clicking the button will cause a screencapture to be taken.
    There are JavaScript libraries that will allow you to execute JavaScript code in a Captivate project that can take a screen capture:
    https://github.com/ariya/phantomjs/wiki/Screen-Capture
    However, to implement these solutions you would need to be quite knowledgeable with setting up JavaScript.  It's not for newbies.

  • How do I create radio buttons which hide certain fields when selected?

    I have a set of two radio buttons, "Yes" and "No"
    When the "Yes" radio button is selected, I would like the "Bank Name", "Branch Number", "Institution Number" and the "Account Number" field to all be blocked from entering content into them.
    When the "No" button is selected, I would like for all of these fields to be available to be written in.
    I can do this currently with check boxes, but the problem with those is that both boxes can be checked at the same time, which is problematic.
    How can I make it so that the radio buttons control whether or not the fields can be written in!
    Thanks very much!

    Yes, I have done this. The buttons are mutually exclusive. The are in the group "Vendor EFT" - one is named "Yes", one is named "No".
    When the "Yes" radio button is selected, I would like the "Bank Name", "Branch Number", "Institution Number" and the "Account Number" field to all be blocked from entering content into them.
    When the "No" button is selected, I would like for all of these fields to be available to be written in.
    Not sure what code needs to be written for this.

  • How do I create a button in an interactive PDF, which will forward the PDF via email?

    Hi,
    So, I have an interactive pdf, with a share button. This button goes to the correct mail program and fills in the subject field.
    But I can't find out how you can add the pdf as an attachment in that e-mail.
    Thanks
    Indy

    Hey vanhaelst,
    You need to have Adobe Acrobat/Reader to attach PDF as an email attachment.
    Select 'Send file as email attachment' icon from the toolbar (as shown below):
    Hope this helps.
    Regards,
    Anubha

Maybe you are looking for

  • My library is a mess, how can I put it in good order?

    I have been backing up my library on different hard drives and over time have added songs from different sources. Subsequently I have several libraries on several hard drives one with 130 gigs of songs one with 190 gigs of songs other with varying am

  • Set tolerance limits in invoice block

    We have the following tolerances:                                                                                 Lower limit                                     Upper limit                                                                             

  • Why can't I sign in to vtok, I cannot access the key pad on my iPad when I try to sign in to vtok. I was able to do it yesterday.

    I am unable to log in on vtok this morning. I was able to do so till yesterday. The key pad does not pop up to type my user I'd and password.

  • Access to an JInternalFrame

    Hi, I have a JFrame with aJDesktoPane. I want to access the current selected JInternalFrame from an "Edit" button within my JMenuBar in my JFrame. Does anyone know, how to get the currently active JInternalFrame?

  • Scheduling Agreements-Not able processes shipments

    When i  try to make  any changes to the delivery document (change/delete) created by the combination of two scheduling agreements  the system shoots an error ME803 dump.txt. I looked at  Note 100690 which says  inconsistency and executed the correcti