Change the color on mouse click

Hi guys.  I followed the code of Ned to another post, whereby if you click on a text button, the color will change.  The code is like

var clicked:Boolean = false;
var clicked2:Boolean = false; 

btn1.addEventListener(MouseEvent.CLICK, btn1click);
function btn1click(event:MouseEvent):void {
    clicked = true; 
    var newColorTransform:ColorTransform = btn1.transform.colorTransform;
    if(clicked){
    newColorTransform.color = 0xc97f22;
    } else {
    newColorTransform.color = 0x000000;
    }
    btn1.transform.colorTransform = newColorTransform;
    gotoAndStop(5);
}
    
btn2.addEventListener(MouseEvent.CLICK, btn2click);
function btn2click(event:MouseEvent):void {
    clicked2 = true; 
    var newColorTransform:ColorTransform = btn2.transform.colorTransform;
    if(clicked2){
    newColorTransform.color = 0xc97f22;
    } else {
    newColorTransform.color = 0x000000;
    }
    btn2.transform.colorTransform = newColorTransform; 
    gotoAndStop(6);
}

Now if I click on the first button, it changes color and stays that way, which is perfect.  If I click btn2, it changes color and still like him.  The problem is that if btn2 is pressed, it should change color and stay as it (as it does), but btn1 should return to its normal color (black).  I don't know how to do this.


Any advice appreciated

See you soon

When you mention that something is another post, it is helpful if you provide a link so that the context of the offered code can be understood. What you choose as a solution, perhaps not the best choice.

Use the following:

var newColorTransform:ColorTransform = new ColorTransform();

var btns:Array = new Array ({btn:btn1, frameNum:5}, {btn:btn2, frameNum:6});})

for (var i: uint = 0; i< btns.length;="">
inclinometer [i].btn.addEventListener (MouseEvent.CLICK, btnclick);
}

function btnclick(evt:MouseEvent):void {}
var frameToGoTo:uint;
for (var i: uint = 0; i< btns.length;="">
If (evt.currentTarget is {btns [i] .btn)}
newColorTransform.color = 0xc97f22;
btns [i] .frameNum = frameToGoTo;
} else {}
newColorTransform.color = 0 x 000000;
}
inclinometer [i].btn.transform.colorTransform = newColorTransform;
}
}

Tags: Adobe Animate

Similar Questions

  • Last update Thunderbird mouse clicks remove two messages at the same time, messages will open in a new tab and more problems! SOLVED by changing the parameters of mouse click

    And please - let's not blame my mouse this time? This is another new since I gave up the old one and broke the LED.

    Now, since this last update, you bird has been going crazy! One, it opens a new message in a new tab. When I select more than one message in order to move them into a subfolder, I get asked: ' opening (number of) X messages can be slow. " Do you want to continue? "Of course I didn't--I just want to move the messages!

    The "Delete" button provided above the message pane is much too sensitive. I want only to delete a SINGLE message at a time - not two or three unless I actually select more than one. Yet these two or three, often with lines of different disciplines, disappear from the window of the object.

    I don't quite know how to describe the latest issue: when I managed to get a message or group of messages, or change files, too often my playback window flashes of full screen to 'Restore down' and vice versa. It's very confusing!

    Yet once again, the question is NOT in my mouse! I think it is in the Thunderbird last "update". Too many "chiefs" (read "developers")?

    Found! Idle speed double-click radically. We'll see if it works. Thanks _much! _

  • How can I add a propertye on a link which, after a mouse click, change the color of the border of the link?

    I am doing this by adding a JavaScript in the box of the binding properties in adobe acrobat 7.0, but I do not know how the script should be written.

    You might do this if you used a button instead of a link annotation and following the mouse upward to the event of the button:

    Change the color of the border of this red button when you click

    event.target.strokeColor = color.red;

    For other colors, see: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.261.html

  • How can I change the color of Minnie Mouse dress?

    Announcements see the dress of Minnie in red, yellow or blue, but I did not understand how this change in the function 'customize '.  It's three different dials or I missed something?

    Hello

    Follow these steps to change the color of the dress of Minnie:

    • While the airtime on the dial of Minnie Mouse, press firmly on the screen, then press the Customize button.
    • Swipe left / right to switch between the three screens of personalization:
      • The first screen allows you to switch between Mickey and Minnie Mouse by turning the digital Crown.
      • With Minnie Mouse selected, the second Customization screen is used to change the color of her dress, once again by turning the digital Crown.
    • When finished, press the digital Crown twice to return to the watch face.
  • Click to change the color of the menu item on

    I want to change the color of menu item (selected menu item), click on a menu item. Please help me if there is any way to do this.

    Thanks in advance.

    No API for this (unless you are using a custom menu)

  • Change the color of the text on the button click

    Hi, how I would change the text with color while the application is running?

    For example, when the user clicks a button, how can I change the color of the editfield with already inserted text?

    I realize that I could add the editifled with different colors, but I was wondering if there is a way to do this without adding new editfield - like refreshing the editfield with different text color.

    Help is very appreciated!

    First, create your own custom class that extends EditField.

    It can be as simple as this:

    public class MyEditField extends EditField {
      private int _color = Color.BLACK;
    
      public void setFontColor(int color) {
        _color = color;
        invalidate();
      }
    
      protected void paint(Graphics g) {
        int prevColor = g.getColor();
        g.setColor(_color);
        super.paint(g);
        g.setColor(prevColor);
      }
    }
    

    Once you have this class, you can use it like this:

    final MyEditField textEntryArea = new MyEditField(...); // any EditField constructor can be used
    
    ...
    FieldChangeListener buttonListener = new FieldChangeListener() {
      public void fieldChanged(Field field, int context) {
        if (field == setToRedButton) {
          textEntryArea.setFontColor(Color.RED);
        } else if (field == setToBlueButton) {
          textEntryArea.setFontColor(Color.BLUE);
        }
        // etc.
      }
    };
    ...
    setToRedButton.setChangeListener(buttonListener);
    setToBlueButton.setChangeListener(buttonListener);
    ...
    

    Edit: fixed a few typos.

  • How can I change the color of the cloth? I tried right click changed to black, gray and even blue but it is still white and mixes with the artboard

    How can I change the color of the cloth? I tried right click changed to black, gray and even blue but it is still white and mixes with the artboard

    It should be present.

  • Change the color of the text to the previous button when you click on a button

    Hi all

    If I said 7 buttons, each with text that changes color on turnover by using 'Up' 'Over' and 'Down' of the keyframes in the timeline buttons.  Is there a simple way to get the text of the button changes color when you click on it, stay that way, and then back to the original color once one of the other 6 buttons are engaged?

    The only thing I can get to prepare code pages for each button that changes the color of every other button regardless of whether it was active.

    See the code example would help a lot!

    Thank you!

    use:

    var previouslyClickedBtn:MovieClip
    var buttonA:Array = [content_mc.work_btn, next button and the rest of your buttons];
    var targetA:Array = [work_mc, etc.];

    for (var i: uint = 0; i<>
    .Ivar Button [i] = i;
    buttonA [i] .addEventListener (MouseEvent.CLICK, clickF);
    buttonA [i] .addEventListener (MouseEvent.MOUSE_OVER, overF);
    buttonA [i] .addEventListener (MouseEvent.MOUSE_OVER, overF);
    }

    function workOver(e:MouseEvent):void {}
    e.currentTarget.gotoAndStop ("over");
    }

    function workClick(e:MouseEvent):void {}

    {if(previouslyClickedBtn!=null)}

    previouslyClickedBtn.gotoAndStop ("up");

    }

    e.currentTarget.gotoAndStop ("down");

    previouslyClickedBtn = e.currentTarget;

    targetA [e.currentTarget.ivar] .gotoAndPlay ("enter");
    }

    function workOut(e:MouseEvent):void {}
    content_mc.work_btn.gotoAndStop ("up");
    }

  • Change the color of text on the button click

    I found many ways to fill out / change the box around a field (both types) but not a way to change the color of the font.

    I tried:

    Form1. Page1.wTextField1.TextColor = ['RGB', 0.5,0.5, 0];

    Form1. Page1.wTextField1.textColor = color.black;

    All hope?

    Try

    Form1. Page1.wTextField1.font.fill.color.value = "0,0,0";

    Steve

  • imunet arrow, how do I change the color of my pointer

    imunet arrow. IWish to darken the color. How?

    Hello

    1. what operating system is installed on the computer?

    If you are using Windows 7 then it is not possible to change the color of the slider, however, you can change the mouse cursor theme. For this try the steps mentioned below.

    (a) open the mouse by clicking the Start button, click on the Control Panel, clicking hardware, and then clicking on the mouse.

    (b) click on the pointers tab, and then do one of the following:

    (c) for all your pointers give a new look, click the list template, and then click a new mouse pointer scheme.

    (d) to change an individual pointer, click the pointer you want to change in the list customize, click Browse, click the pointer you want to use, and then click Open.

  • How to change the color of the same colored sections of an image according to the colorpicker. ?

    Hello.. How are you all... ?


    I do a small program to change the color of these sections of an image that have the same color, according to the chosen of the colorpicker color...


    Say of the colorpicker, we selected a color, and then mouse click on the image event changes the color of those parts of the image that have the same color as the selected portion (or pixel) to the selected color... If we have selected FF0000 in the colorpicker and then clicked 3300CC color pixel in the image. This should change the color of all pixels of color-3300CC in the image...

    I have a colorpicker [colpickr] and a movieclip [mc] the image on the stage. I created a bitmap of the same image (imag1) using the code. Select the color in the colorpicker and a mouse click on the movieclip (here I used getPixel) will change the color in the bitmap image to the selected (with setPixel) color. I have two images; one is a movieclip (inorder to add the listener for the click event), and one is a bitmap (to set the setPixel property). But I need a single image.

    Please help me with this... Below is my code (horrible)...

    import flash.events.MouseEvent;

    Import 12345678910111213import;

    import flash.display.BitmapData;

    import flash.net.URLRequest;

    import flash.display.Loader;

    var c = 0;

    var myBitmapData:BitmapData;

    var bm:Bitmap;

    colpickr.selectedColor = 0xffffff;

    preLoader var;

    var urlReq;

    var preloader_img:MovieClip;

    preLoader = new Loader();

    preLoader.unloadAndStop ();

    urlReq = new URLRequest ("imag1.jpg"); I chose the same image as that of movieclip mc

    preLoader.load (urlReq);

    preLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, preLoaderComplete);

    creates a bitmap of mc...

    function preLoaderComplete(loadEvent:Event) {}

    myBitmapData = new BitmapData (mc.width, mc.height);

    myBitmapData.draw (mc);

    BM = new Bitmap (myBitmapData);

    addChild (bm);

    BM. Width = mc.width;

    BM. Height = mc.height;

    }

    mc.addEventListener (MouseEvent.CLICK, _onMouseClick);

    Gets the color of mc and affects the color bitmap

    function _onMouseClick(event:MouseEvent):void {}

    var myColor:uint = myBitmapData.getPixel (mc.mouseX, mc.mouseY);

    c = myColor.toString (16);

    for (var i = 0; i < bm.width; i ++) {}

    for (var j = 0; j < bm.height; j ++) {}

    If (myBitmapData.getPixel(i,j).toString (16) == c) {}

    myBitmapData.setPixel (i, j, colpickr.selectedColor);

    }

    }

    }

    }

    Try this:

    import flash.events.MouseEvent;

    Import 12345678910111213import;

    import flash.display.BitmapData;

    import flash.net.URLRequest;

    import flash.display.Loader;

    var c = 0;

    var myBitmapData:BitmapData;

    var bm:Bitmap;

    colpickr.selectedColor = 0xffffff;

    preLoader var;

    var urlReq;

    var preloader_img:MovieClip;

    preLoader = new Loader();

    preLoader.unloadAndStop ();

    urlReq = new URLRequest("z_bitmaps/image1.jpg"); / / I chose the same image as that of movieclip mc

    preLoader.load (urlReq);

    preLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, preLoaderComplete);

    creates a bitmap of mc... ;

    function preLoaderComplete(loadEvent:Event) {}

    BM = Bitmap (loadEvent.target.loader.content);

    addChild (bm);

    }

    stage.addEventListener (MouseEvent.CLICK, f);

    function f(e:MouseEvent):void {}

    If (BM.hitTestPoint (MouseX, MouseY) &! colpickr.hitTestPoint (mouseX, mouseY)) {}

    _onMouseClick (e);

    }

    }

    Gets the color of mc and affects the color bitmap

    function _onMouseClick(event:MouseEvent):void {}

    c = BM. BitmapData.GetPixel (BM. MouseX, BM. MouseY);

    for (var i = 0; i)

    for (var j = 0; j)

    If (bm.bitmapData.getPixel (i, j) == c) {}

    bm.bitmapData.setPixel (i, j, colpickr.selectedColor);

    }

    }

    }

    }

  • Change the color of the cursor

    Hello

    I have a simple coloring book that I have developed. I have almost all of the work, but I can't get the cursor on the current color to a range of color.

    The cursor is a movieclip called 'mycursor_mc' it is a clip inside of this so-called "CursorFill. I'm trying to get the clip of "CursorFill" to change the value currentColour of the dynamic property array index.

    This is the section, I was working on but it does not work:

    var mycursor_mc:cursor = new cursor();

    addChild (mycursor_mc);

    var m = new CursorFill();

    mycursor_mc. AddChild (m);

    Here's the Action script:

    Table to hold the colors

    var colorArray:Array = new Array(0xE97DB1,0xF58240,0xF9ED41,0x82C34D,0x00B0F0,0x935CA4,0xFFFFFF);

    A new instance of the class of color transformation.

    var colorTrans:ColorTransform = new ColorTransform;

    var currentColor:int = 0;

    This adds the ovals on the scene with the corresponding color of the table

    and the mouse click events.

    for (var i: int = 0; i < colorArray.length; i ++) {}

    var marker: Sprite = new Sprite();

    Marker.y = 500 + i * 50;

    var c = new MarkerFill();

    c.buttonMode = true;

    marker.addChild (c);

    colorTrans.color = colorArray [i];

    c.transform.colorTransform = colorTrans;

    c.addEventListener (MouseEvent.CLICK, ovalsClick);

    c.arrayIndex = i;

    var o: Outline = new Outline();

    marker.addChild (o);

    addChild (marker);

    }

    This creates a new instance of the slider clip and adds on

    the scene using the addChild method.

    var mycursor_mc:cursor = new cursor();

    addChild (mycursor_mc);

    var m = new CursorFill();

    mycursor_mc. AddChild (m);

    Hides the cursor by default on the stage, so it will not display.

    Mouse.Hide ();

    Adds an event listener on the stage with the enter frame event that

    on several occasions the latter runs the moveCursor function.

    stage.addEventListener (Event.ENTER_FRAME, moveCursor);

    This feature enabled the x, y of the slider positions customized to the x & there posts

    the default cursor.

    function moveCursor(event:Event) {}

    mycursor_mc.x = MouseX;

    mycursor_mc.y = MouseY;

    }

    This sets the value of currentColour of dynamic property array index.

    function ovalsClick(e:MouseEvent):void {}

    currentColor = e.currentTarget.arrayIndex;

    }

    Adds the mouse click event to the holder.

    holder.addEventListener (MouseEvent.CLICK, holderHandler);

    This function changes the color of the clip to the inside

    When he is selected.

    function holderHandler (e:MouseEvent): void {}

    for (var i: int = 0; i < holder.numChildren; i ++) {}

    If (holder.getChildAt (i) .hitTestPoint (mouseX, mouseY, true)) {}

    colorTrans.color = colorArray [currentColor];

    holder.getChildAt (i).transform.colorTransform = colorTrans;

    }

    }

    }

    It's strange. Try to draw a few things so that everything works as it should:

    function ovalsClick(e:MouseEvent):void {
         currentColor = e.currentTarget.arrayIndex;
    
         trace(e.currentTarget, currentColor, colorArray[currentColor]);
    
         var trans:ColorTransform = new ColorTransform();
         trans.color = colorArray[currentColor];
         m.transform.colorTransform = trans;
    }
    
  • static_text change the color of text to the flight hover/rollover?

    Hello

    If you have a look at export to Facebook plugin by Jeffrey Friedl, its Plugin Info dialog box includes static_text items that change color when the mouse passes over them.  A while back I posted on initiate an action when a user clicks on an element of static_text.  He used this to inidcate when static_text elements are interactive, and I want to do it too.  Unfortunately, Jeffrey is unable to talk about it.

    Someone (Eric?) can do the light on this field should be added to static_text to do this?  I know how to turn clicks left and right of the mouse on an item of static_text but have not figured out how to react to the other mouse events yet.

    Thank you

    Matt

    WARNING: What you see here is undocumented, unsupported, could shatter at any moment, should not be used to control the core functions such as the landing of aircraft, blah, blah blah, etc. etc.  Use at your own risk - it is for you to make it work.  I have no recollection of ever typing this, so can not be held responsible. 

    Phew!  In any case, a few months ago, I asked Jeffrey Friedl the same question.  His answer:

    I asked (and was given) authorized to tell you:

    {static_text: f}
    title = 'Visit the Site',
    MOUSE_DOWN = function()
    LrHttp.openUrlInBrowser (someUrl)
    end,
    [WIN_ENV and 'adjustCursor' or 'adjust_cursor'] = function()
    Recorder: debug ('mouse_over handler activated')
    end,
    appears = LrColor (0, 0, 1),
    }

    Enjoy!

    When asked if I could share information, he replied:

    Approval did not come with restrictions, so I guess it's normal to
    spread around.

    In any case, the critical part of the code snippet that is missing is what to do in the «mouse_over Manager» feature  What I did to all of my links was to call a common function that would launch an asynchronous task that could change the color of the link, then change it after some time.

    I went 'self' (static_text being flown over) to my current routine, so he could follow the active link and reconnect precedent, when the user is pointing somewhere new.

    Good luck and, as Jeffrey says: Enjoy!

    -Don

  • How can I change the color of the mixture without polydioxanone it?

    If I have a simple mixture of two lines, and to change the color, I'm going to > objectives > mix > release of mixture and then change the color by selecting and changing the shade of the race.  So, I have to redo the mix and eventually reapply the mixture settings.  I'm generally uncertain of color combinations and working things by trial and error so sometimes, it's a lot of clicking. I know there is a keyboard shortcut for the release of mixture, but it's always a chore if you use a stylus or a mouse.

    It's what lies beneath my question - is there a quick way to change the color of a vector that is part of a mixture?

    Thank you

    Martin

    You need not leave the mix to change the color. Use of the

    tool Direct Selection to select only one race at the beginning or at the end

    the mixture, which will allow you to change the color and the mixture

    updates automacly. You can also select the entire mixture and use

    -LiveColor to change the color of each object that make the mixture in

    only once.

  • Pages 5.6.2, cannot highlight and change the color of the text?

    I use pages 4.3 and earlier of passage to 5.6.2 - I just tried to highlight a word in a document and change the color - nothing happened.  Tried selecting the color first, and then type a new Word and that doesn't work either.  Am I missing something?  Is there any quick way to the color of the text in 5.6.2?

    To well highlight a word or a selection of words in the v5.6.2, Pages you will need to select the text, click the image below on the gear watch icon and set the fill color of your character. To remove the highlight, select your text, click in the ink of fill color of characters and click transparency icon in the lower right.

Maybe you are looking for

  • Cannot control ARD 3.8.5 customers using 3.8 ARD on 10.11

    Recently upgraded my station and a few customers to 10.9.5 10.11.1 I use ARD 3.8 for various daily tasks. Push files, control the client stations support etc. The stations that I have not been updating still - running 10.9 & ARD 3.8.4 customer I can

  • Sound card prob

    Hello guys it, s been a sense I used my laptop since the death of my audio card due to problems of unknow somehow I was wounering if none know what kind a sound will be support/compitable with my m system so I can replace or if hp sell Please I need

  • ActiveSync: *.favorites is not a valid short file name *.

    Help me!!! I am engineer in a DoD environment.  We had a problem with title error ".favorites is not a short file name.  The error message is displayed when a typical user with any escalated authorization attempts to run ActiveSync.  ActiveSync insta

  • Recovery partition resizing...

    OK, something similar has already been asked here, but I have something slightly different. I want to resize my recovery partition to make it much larger and store data on this subject. Would he then still work as a recovery partition?

  • UCCX call lines expectations

    Currently we run 8.0.2 UCCX and have a multi queue helpdesk.  Agents have multiple skills assigned to them.  We have a request now add a prompt to just 1 queue which will increase the priority of this call and only affect this queue.  From my underst