A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22

Thread: Show image when button is clicked

  1. #21
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    You can do it a few ways but here is one, code and fla
    PHP Code:
    import flash.geom.ColorTransform;
    import flash.events.MouseEvent;

    var 
    newColour:ColorTransform = new ColorTransform();
    var 
    oldColour:ColorTransform = new ColorTransform();

    var 
    buttonArray:Array = new Array(circle1,circle2,circle3,circle4);
    var 
    newCol:uint 0xFFFFFF;
    var 
    oldCol:uint 0x000000;

    var 
    i:Number;

    for (
    0buttonArray.lengthi++)
    {
        var 
    colourButton:Object buttonArray[i];
        
    colourButton.buttonMode true;
        
    colourButton.value i;
        
    colourButton.addEventListener(MouseEvent.CLICKdoColours);
    }

    function 
    doColours(e:MouseEvent):void
    {
        for (
    0buttonArray.lengthi++)
        {
            
    oldColour.color oldCol;
            
    buttonArray[i].transform.colorTransform oldColour;
        }
        
    newColour.color newCol;
        
    e.currentTarget.transform.colorTransform newColour;

    or you could just make each clip gotoAndStop(2); by swapping
    PHP Code:
    function doColours(e:MouseEvent):void
    {
        for (
    0buttonArray.lengthi++)
        {
            
    oldColour.color oldCol;
            
    buttonArray[i].transform.colorTransform oldColour;
        }
        
    newColour.color newCol;
        
    e.currentTarget.transform.colorTransform newColour;

    for

    PHP Code:
    function doColours(e:MouseEvent):void
    {
        for (
    0buttonArray.lengthi++)
        {
            
    buttonArray[i].gotoAndStop(1);
        }
        
    e.currentTarget.gotoAndStop(2);

    and frame 2 would be the colour you required, no need for any of the colorTransform stuff then
    Last edited by fruitbeard; 01-20-2015 at 08:20 AM.

  2. #22
    Member
    Join Date
    Nov 2014
    Posts
    34
    The first one. Exactly as I needed. Thanks a lot!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center