A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Color changing help

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Posts
    2

    Color changing help

    Hey all,

    I feel sort of stupid asking this, but for the life of me I cant seem to find/figure out an answer to this script.

    I am trying to create a simple little script to change the color of a circle every time the user clicks anywhere in the flash movie. I swear that the code below should work and I cant find out where I am going wrong. Help, please? (er side note, I just realized that the code that I posted wont change it *everytime* but at this point I just want to be able to change it at all. I'll work on it from there)

    class shooter extends MovieClip
    {
    function onLoad()
    {
    shooter.onRelease(mouseDown)
    {
    var colorful = new Color("_root.shooter_ball");
    colorful.setRGB(0x0000FF);
    }
    }

    }

  2. #2
    Junior Member
    Join Date
    Aug 2009
    Posts
    6
    try without the " :
    var colorful = new Color(_root.shooter_ball);
    or just:
    var colorful = new Color(shooter_ball);

    but If you are trying to use this in CS3:

    "The method Color is no longer supported. The Color class has been removed. Use the flash.geom.ColorTransform class for equivalent functionality.."

  3. #3
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    For AS3, try something like this,
    PHP Code:
    var cir:Sprite = new Sprite();

    cir.graphics.beginFill(0xFF00001);
    cir.graphics.drawCircle(20025030);
    cir.graphics.endFill();
    addChild(cir);

    stage.addEventListener(MouseEvent.CLICKmClickfalse0true);

    function 
    mClick(e:MouseEvent):void {
        var 
    ct:ColorTransform = new ColorTransform();
        
    ct.color Math.random() * 0xFFFFFF;
        
    cir.transform.colorTransform ct;

    Wile E. Coyote - "Clear as mud?"

  4. #4
    Junior Member
    Join Date
    Aug 2009
    Posts
    2

    Clarification

    I am working with CS4 but I'm using Actionscript 2. Was the Color function removed in Actionscript 3 or just Creative suite 3?

  5. #5
    Senior Member Robb@exo's Avatar
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    1,540
    Removed in AS3.
    Wile E. Coyote - "Clear as mud?"

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