Change button color

  • falcondesign
  • Born
  • Born
  • falcondesign
  • Posts: 3

Post 3+ Months Ago

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
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

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.
  • falcondesign
  • Born
  • Born
  • falcondesign
  • Posts: 3

Post 3+ Months Ago

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
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

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.
  • falcondesign
  • Born
  • Born
  • falcondesign
  • Posts: 3

Post 3+ Months Ago

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
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

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. }
  • samwipro
  • Born
  • Born
  • samwipro
  • Posts: 1

Post 3+ Months Ago

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 4 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.