Change button color

  • falcondesign
  • Born
  • Born
  • No Avatar
  • Joined: Oct 21, 2004
  • Posts: 3
  • Status: Offline

Post October 21st, 2004, 11:26 am

I have a set of buttons that laod a .swf. Now i want, after you press that button and it loads that .swf for that corresponding button to change color so that the user knows which one they clicked. And then when you click on the others it would do the same. Is this possible?

I figure its probaby some actionscript coding that i am not advanced enough to do yet. Any feedback would be most apprecaited! Thank you

D
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 21st, 2004, 11:26 am

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post October 21st, 2004, 12:35 pm

Are you using the component button that comes with flash or a custom button ?

If you're using the components then take a look in,
Window > Reference (shift + F1)
In the - Flash UI components > FStyleFormat - Book.

If it's a custom button you need to have an instanceName on the part of the button you want to change color, & attach a color object to it.

If your button has a background mC named "bg" you would edit the mC & on the timeline have,
Code: [ Select ]
this.colorObj = new Color(bg);

back out of edit mode, & on the button itself have,
Code: [ Select ]
on(press){
this.cObj.setRGB("0x123456");
//rest of actions
}
  1. on(press){
  2. this.cObj.setRGB("0x123456");
  3. //rest of actions
  4. }

You can read more about the color object in the,
Objects > Movie > Color - book of the reference window.
Strong with this one, the sudo is.
  • falcondesign
  • Born
  • Born
  • No Avatar
  • Joined: Oct 21, 2004
  • Posts: 3
  • Status: Offline

Post October 21st, 2004, 12:41 pm

That works yes, but how do i make it change back to its original color after another button is pressed? is there a simple if statement that would work. I'm not sure.

Thank you
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post October 21st, 2004, 4:50 pm

Easy way, make a _global variable to hold the last clicked buttons color Object, on the main timeline you'll have
Code: [ Select ]
_global.lastClicked = false;

On the buttons you'll have
Code: [ Select ]
on(press){
 if(lastClicked){
  lastClicked.setRGB(unClickedColor);
 }
 this.cObj.setRGB(clickedColor);
 lastClicked = this.cObj;
}
  1. on(press){
  2.  if(lastClicked){
  3.   lastClicked.setRGB(unClickedColor);
  4.  }
  5.  this.cObj.setRGB(clickedColor);
  6.  lastClicked = this.cObj;
  7. }

When a button is pressed that lastClicked variable is pointing to a color object which is attached to a movieClip, the if statement just checks that a button has been pressed at least once.
Strong with this one, the sudo is.
  • falcondesign
  • Born
  • Born
  • No Avatar
  • Joined: Oct 21, 2004
  • Posts: 3
  • Status: Offline

Post October 22nd, 2004, 11:10 am

you said this: "When a button is pressed that lastClicked variable is pointing to a color object which is attached to a movieClip, the if statement just checks that a button has been pressed at least once."

But i was wondering if you could do it to the button itself without attaching color objects to movie clips cause i'm not too familiar with doing that?
  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post October 22nd, 2004, 12:50 pm

Well.. You could create two movieclips for everything you want to have change color & swap out _visible properties with them. The global variable pointing to the lastClicked would still apply.

That would change the on(press) above to somthing like this,
Code: [ Select ]
on(press){
 if(lastClicked){
  lastClicked.offMC._visible = true;
  lastClicked.onMC._visible = false;
 }
 this.onMC._visible = true;
 this.offMC._visible = false;
 lastClicked = this;
}
  1. on(press){
  2.  if(lastClicked){
  3.   lastClicked.offMC._visible = true;
  4.   lastClicked.onMC._visible = false;
  5.  }
  6.  this.onMC._visible = true;
  7.  this.offMC._visible = false;
  8.  lastClicked = this;
  9. }
Strong with this one, the sudo is.
  • samwipro
  • Born
  • Born
  • No Avatar
  • Joined: Apr 25, 2008
  • Posts: 1
  • Status: Offline

Post April 25th, 2008, 12:59 pm

Can you please tell me how can I set RGB from VB6.

var colorful1 = new Color("_root.shapes");
colorful1.setRGB(abc);

where abc is the variable name passed from VB6 where "abc2 = "0x339900")

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 38 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.