dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [F8] Background color

  1. #1
    Intermediate Game Dev pseudobot's Avatar
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    561

    [F8] Background color

    Is it possible to change the background color of a flash application using actionscript? The thing is, I have made a game with quiet a lot of menus/submenus, and when you enter a specific cheat-code, it changes the cursor to yellow.

    So, is it possible to change the default background color using actionscript?
    Thanks in advance!

  2. #2
    Jack Foster cabbar's Avatar
    Join Date
    Feb 2007
    Location
    England
    Posts
    111
    best practice would be to create a small MovieClip on the Stage,
    something like 10x10
    and set its x and y = 0;
    and give it an instance name of bg_mc
    then you can script it to change the colour to the width and heigh of the stage.


    firt create a function to set the bg_mc colour, in this case its black.

    function bgChange(toThisColour) {
    var colour = new Color(bg_mc);
    colour.setRGB(toThisColour);
    bg_mc._width = Stage.width;
    bg_mc._height = Stage.height;
    }
    bgChange(0x000000);

    then use your buttons to change the colour

    b1.onRelease = function() {
    bgChange(0xff0000);
    };
    b2.onRelease = function() {
    bgChange(0x00ff00);
    };
    b3.onRelease = function() {
    bgChange(0x0000ff);
    };

  3. #3
    Jack Foster cabbar's Avatar
    Join Date
    Feb 2007
    Location
    England
    Posts
    111
    here is the fla for it, it may be use for others too...
    Attached Files Attached Files

  4. #4
    Intermediate Game Dev pseudobot's Avatar
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    561
    ^I understand that that works, but what Im interested in is changing the Default color of the stage, and not use a movie clip. Im pretty shure there's a variable for it, right?

  5. #5
    Intermediate Game Dev pseudobot's Avatar
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    561
    Oh, and thanks for the help too, cabbar!

  6. #6
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    without using an mc, no.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

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