Be a Supporter!

Fast color swap?

  • 641 Views
  • 5 Replies
New Topic Respond to this Topic
keeth33
keeth33
  • Member since: Jan. 18, 2008
  • Offline.
Forum Stats
Member
Level 08
Animator
Fast color swap? 2011-11-08 00:36:49 Reply

im working on a project that i will require to switch between two colors to do it within the time i am given. is there a key or some method that i can use to switch between two colors?

ProfessorFlash
ProfessorFlash
  • Member since: Oct. 6, 2007
  • Offline.
Forum Stats
Member
Level 32
Programmer
Response to Fast color swap? 2011-11-08 01:20:01 Reply

It's not clear what you are trying to do. Explain the situation better please.


You can solve pretty much any problem you may have with AS3 by consulting the AS3 Language reference.

Nae
Nae
  • Member since: Jan. 14, 2009
  • Offline.
Forum Stats
Member
Level 01
Artist
Response to Fast color swap? 2011-11-08 02:14:59 Reply

You could add a new layer and put two shapes filled with the colors you need on it (just off the stage). Then use keyboard shortcuts to switch between tools... like the bucket and the eyedropper. When you're done, delete the layer with the swatches.

Or you can select one color for the stroke and the other for the fill ...then click 'swap colors' to toggle between them ...as far as I know there's not a shortcut for that.

Fast color swap?


"Why do you hide, stupid aliens? Mr. Zurkon only wishes for to kill you."

BBS Signature
iluvAS
iluvAS
  • Member since: Nov. 18, 2007
  • Offline.
Forum Stats
Member
Level 08
Game Developer
Response to Fast color swap? 2011-11-08 03:02:18 Reply

If you're talking about tinting objects on runtime, you gotta look into color transform. Imma help you kick start with a portion of my color manipulating library. Other than this you got to know how to use timer event since you want it to be something that gets executed by time, or maybe u can just use a variable to substitute as a timer.

yourObj.transform.colorTransform = interpolateColor(new ColorTransform(), 0xFF0000, 0.5);
// tints your object to red by 50%

function interpolateColor(start:ColorTransform, col:uint, perc:Number):ColorTransform
{
	var end:ColorTransform = new ColorTransform();
	end.color = col;
			
	var result:ColorTransform = new ColorTransform();
	result.redMultiplier = start.redMultiplier + (end.redMultiplier - start.redMultiplier) * perc;
	result.greenMultiplier = start.greenMultiplier + (end.greenMultiplier - start.greenMultiplier) * perc;
	result.blueMultiplier = start.blueMultiplier + (end.blueMultiplier - start.blueMultiplier) * perc;
	result.alphaMultiplier = start.alphaMultiplier + (end.alphaMultiplier - start.alphaMultiplier) * perc;
	result.redOffset = start.redOffset + (end.redOffset - start.redOffset) * perc;
	result.greenOffset = start.greenOffset + (end.greenOffset - start.greenOffset) * perc;
	result.blueOffset = start.blueOffset + (end.blueOffset - start.blueOffset) * perc;
	result.alphaOffset = start.alphaOffset + (end.alphaOffset - start.alphaOffset) * perc;
	return result;
}

BBS Signature
keeth33
keeth33
  • Member since: Jan. 18, 2008
  • Offline.
Forum Stats
Member
Level 08
Animator
Response to Fast color swap? 2011-11-08 08:14:56 Reply

sorry about not explaining the situation well enough, though i got the answer i needed. thanks guys!

Nae
Nae
  • Member since: Jan. 14, 2009
  • Offline.
Forum Stats
Member
Level 01
Artist
Response to Fast color swap? 2011-11-09 10:59:49 Reply

At 11/8/11 08:14 AM, keeth33 wrote: sorry about not explaining the situation well enough, though i got the answer i needed. thanks guys!

Glad you got it sorted! Care to share the answer? ...in case someone else has a similar situation. Thanks :)


"Why do you hide, stupid aliens? Mr. Zurkon only wishes for to kill you."

BBS Signature