Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Changing Object Color Using ActionScript



First hello to everyone from a newbieAnd now to the problem..i want to change color of an object via AS, which seems simple enough but stay with me. Id already seen http://www.kirupa.com/developer/actionscript/color.htm but here the object processed is made of multiple rectangles and my object cannot be really made of it. To be more precise, i want to create an image of an house and change it's color. I tried drawing it with lines, then making it a symbol and change it according to the tutorial but all i accomplished is changing the color of lines. Anyone has another suggestion?Thanks in advance



KirupaForum > Flash > Flash 8 (and earlier)
Posted on: 10-12-2006, 02:41 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Changing The Color Of An Object In Actionscript
Is it possible to change the tint/color of an object in Actionscript and if so, how?

Cheers

Changing An Object's Color
i have this old piece of code:

Code:
if (Number(charinline)<=Number(linelen)) {
duplicateMovieClip("/fx_" add fx add "_0", "char" add i, i);
set("/char" add i add "/letter/lettercolor:char", key);
setProperty("/cursor", _x, Number(startx)+Number(charinline*kerning)-20);
setProperty("/char" add i, _x, Number(startx)+Number(charinline*kerning));
setProperty("/char" add i, _y, Number(starty)+Number(linenum*linespace));
charinline = Number(charinline)+1;
i = Number(i)+1;
}
... which duplicates and places mc named "char[i]" on the stage based on predetermined _x & _y values, now i need to change the color of said mc. how can i do that? i've been trying to find a way but i gave up after 3 hours.

any help will be greatly appreciated

thanks much
- w

Changing Object Color With AS
hi I am trying to make a smooth color transition using AS2

the way I have now the mc changes colors just fine, but not smooth like when you use tween. I know there is a 'get Transform' function but I don't know how to apply maybe someone has an example??


Code:
function changeBG(col) {
var c = new Color(_root.bg);
c.setRGB(col);
}
changeBG(0xCC3366);

Can I Get Some Help With Changing The Color Of An Object?
I'm trying to make the following - I have 5 buttons corresponding to five sections in my Flash movie..I want to make it so, that when I click on a button it background color changes(to show that it was clicked and I'm in that section)...
The button is located inside a movieclip(not in the root timeline)...
For the purpose I converted the background of the button (which I want to change) to a movie clip, so I could use the "setRGB" command, but still I'm doing something wrong and nothing happens...
Can someone explain to me clearly the mechanism of changing the color of a movie clip?

Thanks in advance!

Changing The Color Of An Object
Hi

I want to make something like a children's paint book. The user will choose the color from a palette and when she clicks an object, that object will seem in that color.

Anyone knowing a tutorial about it, or any suggestions on how to accomplish this?

Thanks in advance

Changing The Color Of Clicked Object
Hi,

I'm looking for a way to change the color of the object that I click on. Something like a paint program where you first click to select the color and then click on the place which you want to color.

Thanks

Greg

Changing Instance Or Object Color
does anyone know of a script that will change an object color?

eg: I have a white box, on button1 press I want it to go blue, on button2 press it will go red etc.

so is it possible?

thanks if anyone can help! would be tops!

zanga

Changing The Color Of An Object At Every Execution
I have a problem:

I have one file, template.as, this file keeps color configuration to make changes of my site.
I would like to know if it is possible to change color of an object every time of execution (run time).
I am using setRGB() function to make these changes.
The variable that defines the template that will be used is loaded with loadVariablesNum() function.
My script works only when I compile my movie clip (generate .swf)
I want to change the colors without having to "compile" my movie every time.

If someone can help me with other functions or any other way to do this, I will be very grateful.

Thanks

Changing Color Of Imported Object
Hi,

i am trying to change color of imported swf file from another swf, let say i have a swf names fileparent and inside mc with instant name stage. in that stage i have some controls of color boxes i have imported another swf using AS on stage. imported swf have some layers with different objects of different colors i want to change color of every object separately. i dont know how to access that object inside imported swf.

just need to know the way to get inside imported object.

see an example here

http://www.bluecotton.com/studio.htm...175&garColor=1

thanks in advance

Gradually Changing The Color Of An Object
What I want to do is to transition the color of an object to a different color gradually. In other words, in frame 1 i have a light gray circle. In frame 30, I have a dark gray circle. I want to show a smooth transition from the light gray to the dark gray. Can this be done with a motion tween?

So Easy, I Can't Do It - Changing Object Color
I draw a circle on the stage.

I select it and save as symbol, i call it mc_circle and "export to action script" as my_mc_cirle

I cannot get the circle to change color using what I imagine should be a 1 liner. Very frustrated


my_mc_circle.setRGB(0x0000CC);
and
mc_circle.setRGP(0x0000CC);

are doing nothing??

Changing The Color Of An Object/movie Clip
I had an object that I wanted to be visible and invisible at my choosing... had to change it to a movie clip (this seems silly to me... you should be able to do it to objects)... but now I want to change the color of this movie clip object at the click of a color... how would I go about doing this... I tried this without success:
c=new Color(img_boy);
c.setRGB( 0x000000 );

Thank you

Changing MC Color With ActionScript?
Hello,

Anyone know how to change the RGB values of a MC using ActionScript?

thanks,
Janet

Changing Color With Actionscript
Does anyone know how I would change the color of a movieclip using actionscript?

I'd love to use a tween (like you can for alpha but one isn't available for color as far as I know).

Changing Color Via Actionscript
i want to change a movie clip's tint to black

how do i do this?

Changing The Color Of An _mc Using Actionscript
how would I alter this AS to make the mc change color, the advanced portion of the color setting looks like this, R = (100% x R) + 163, when I get the mc to the right shade.. heres the AS


ActionScript Code:
on(rollOver, dragOver){    fade = "out";}on(rollOut, dragOut){    fade = "in";}on(release) {          this.onEnterFrame = function() {         if (_level10._alpha > 0) {             _level10._alpha -= fade_speed;             } else {              delete this.onEnterFrame;             _level10._alpha = 0;             loadMovieNum("tour.swf","10");             }    }}onClipEvent(enterFrame){     if(fade == "in"){        this._alpha += 30;//or however fast you want it to fade...        if(this._alpha >= 100){            delete fade;        }     }     if(fade == "out"){         this._alpha -=30;          if(this._alpha <= 70){           delete fade;          }      }}


any help would be great, thanks.

Changing Color With Actionscript
Hi there

I've seen the tutorial on changing colours randomly with a button press but I was wondering if there was something slightly different available to help me.

I want to click on a button and have certain elements onscreen transition to a specific colour over the space of 2 seconds approx. the basic idea is to be able to skin the site and pick the monochromoatic colour scheme.

Can anyone help me out with this?

thanks much for any input!!
SS

Color Changing With Actionscript?
I want to change the color of text in a movie clip but i want it to fade in... how can i create this tween via actionscript.

Changing The Color Of A Text Using Actionscript
Hi !

Is it possible to change the color of the text through action script ? (If it's not possible in straight way, then using any trick like putting the text in a movieclip & then changing the color of the movie clip etc.)


Mahesh

Color Changing Buttons With Actionscript
hello. right now i'm working on a menu for a flash movie. when you mouse over the buttons, i've got this neat effect where the background is filled with this pixel animation, which is hard to describe. for your benifit this is a link to a sample of my menu with the effect in place:

http://web.ics.purdue.edu/~johns113/blog/menu.html

what i'm trying to do is make it so the blue color is scriptable via a hex color code stored in a variable in the main timeline (that way i can dynamically change the colors of the menu via parameters loaded into the movie from the html page the flash movie is on). the pixel animation is just a mask over a blue colored background area. I made the background a movie clip to try and use the color object so i could do setRGB, but that dosn't seem to work for some reason. if you need, I can email the .fla movie so you can see how i've got things constructed. thanks for your help, and I hope someone has an answere for this.

Changing Background Color Via Actionscript
how do i change the background of MC through Actionscript?

Changing The Color Of A Font Using Actionscript
I several buttons and on the over event those buttons change to diffent colors. What i would like to do is change the color of the font in the text field based on the color of the button. Can this be done thru code or do I have to create multiple text fields.

Dollarbillg

Changing Textbox Color With Actionscript
I am a little confused. I have a text box I named "letter". I want the background of the textbox to be the same color as a graphic it sits on top of.

In the first frame of the movie, I assign the text to the textbox and set the background color like this:

letter = "falskdfjakld j";
letter.backgroundColor = "FFE8D6";

I get the text but I don't get the background color of the textbox to change.

Where does the letter.backgroundcolor code go?

Using Flash 5.0

I would appreciate the help.

Thanks,

Jef

Changing Button Color Actionscript
How do I change the color of a button onPress with actionscript?

Here is what I have so far...

http://glennon.org/2004Tour/tour.htm

What I am looking to do is when a user clicks on say, "Ground, Floor1, Floor2, or Floor3" I want that button to stay blue just so they know what Floor there on.

How do I do that?

Right now for example on Ground I have this AS...

on (release) {
_root.subBox.attachMovie("ground","subbuts",1);
}

When I try to give the Button an instance name like "Ground" and say...

Ground.SetRGB("whatevercolor");

It does not work.

Please help.

Changing Background Color With Actionscript
Greetings from france...

I'm trying to change the background color of a movie...

I've tryied

bgcolor = new Color(_root);
bgcolor.setRGB(0xF20000); // (red)

But that just adds a color to every single movieclip on stage... Without changing the background color...

Please help...

Thanks in advance

Changing Background Color With Actionscript
Greetings from france...

I'm trying to change the background color of a movie...

I've tryied

bgcolor = new Color(_root);
bgcolor.setRGB(0xF20000); // (red)

But that just adds a color to every single movieclip on stage... Without changing the background color...

Please help...

Thanks in advance

Changing Text Color W/ Actionscript
Hi,

I am looking for a script that I can attach to a button that will then change the text (inside a dynamic text box) to a specified color. So, when I click the mouse on the button, the text in the dynamic text field will change to the color that I have specified in the script. Thanks so much for your help!

Changing Color (colour) Using ActionScript Buttons
Hey guys, sorry to bug you all, but I'm hoping you can help a budding ActionScripter!

I'm trying to make it so when the user clicks a button, it fades from it's current colour to a pre-defined one... simple enough in theory

Here's the AS I've got so far:


Code:
var startColour = {r:50,g:100,b:250};
var endColour = {r:250,g:0,b:120};

function fadeColour(startColour,endColour,t) {
var newR = (endColour.r - startColour.r)*t + startColour.r;
var newG = (endColour.g - startColour.g)*t + startColour.g;
var newB = (endColour.b - startColour.b)*t + startColour.b;
new Colour(but01).setRGB( newR << 16 | newG << 8 | newB );
}


but01.onRelease = function() {
t += 0.1; // Fade Speed
if (t < 1) {
fadeColour(startColour,endColour,t);
} else {
fadeColour(startColour,endColour,1);
}
}
So, let me just walk you thru a few things...

The script works, but not as hoped. The colour will only change when the user is "clicking" on the button, I want to it keep changing colour until it reaches the 'endColour' variable (like it should) - I have tried doing an "onRelease" statement, but this didn't help either

Secondly, like I said in my preamble, I want it to be able to fade from its current colour to a set colour, eg: I need var startColour to be dynamic, rather than fixed, but I don't know how to read in an objects current colour(!) - any ideas?

Thanks guys.
jonny.

Changing Color (colour) Using ActionScript Buttons
Hey guys, sorry to bug you all, but I'm hoping you can help a budding ActionScripter!

I'm trying to make it so when the user clicks a button, it fades from it's current colour to a pre-defined one... simple enough in theory

Here's the AS I've got so far:


Code:
var startColour = {r:50,g:100,b:250};
var endColour = {r:250,g:0,b:120};

function fadeColour(startColour,endColour,t) {
var newR = (endColour.r - startColour.r)*t + startColour.r;
var newG = (endColour.g - startColour.g)*t + startColour.g;
var newB = (endColour.b - startColour.b)*t + startColour.b;
new Colour(but01).setRGB( newR << 16 | newG << 8 | newB );
}


but01.onRelease = function() {
t += 0.1; // Fade Speed
if (t < 1) {
fadeColour(startColour,endColour,t);
} else {
fadeColour(startColour,endColour,1);
}
}
So, let me just walk you thru a few things...

The script works, but not as hoped. The colour will only change when the user is "clicking" on the button, I want to it keep changing colour until it reaches the 'endColour' variable (like it should) - I have tried doing an "onRelease" statement, but this didn't help either

Secondly, like I said in my preamble, I want it to be able to fade from its current colour to a set colour, eg: I need var startColour to be dynamic, rather than fixed, but I don't know how to read in an objects current colour(!) - any ideas?

Thanks guys.
jonny.

How Can I Assign A Rgb Color To Object In ActionScript
I've created sliders with r g b channels. so i have an rgb values of the color. Then i have an object and i know only one way assigning colors is the Color object which required hex value of color. And how can i convert color to hex.... or there ios another way....Help me plz.

Changing An Object Size Through Actionscript
I am looking for a way to make objects bigger and smaller through actionscript. I guess the code should look something like this. Thanks in advance for any help.

this.height = this.height+1;
this.width = this.width++;

-j

Changing Object Colors With Actionscript
Hi guys... im new to the forum and consider myself a novice actionscripter... i have lofty goals in terms of the script that im trying to write, admittedly my understanding at any given moment may be zero... anyway here is what id like to accomplish with the click of a button:

id like to change the color of my movieclips when the user clicks a button also in that moment id like to load and unload movies into an empty clip in my main timeline? am i in over my head as a beginner or is there a short a sweet code for this? -if i have to i will create various scenes and labor over it to reach my desired effects but i know through actionscript there has to be a better way -can anyone point me in the right directions? please?

Changing Fill Color And Line Color Dynamicly And Seperately
Hi community,

In this case, I am going to load a swf with a looping animation colored in black and white only. I want to change the color of the animation dynamicly so that I could have different color at each time. Here is my code:


Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import flash.display.*;
import flash.net.URLRequest;

private function init():void{
myCan.addEventListener(Event.ENTER_FRAME,capMotion);
}
private function capMotion(event:Event):void{
var bmd1:BitmapData = new BitmapData(mySwf.width, mySwf.height, true, 0x00CCCCCC);
bmd1.draw(mySwf);

var bitmap1:Bitmap = new Bitmap(bmd1);
bitmap1.x = 0;
bitmap1.name="org";
if (map.getChildByName("org") != null){
map.removeChild(map.getChildByName("org"));
}
map.addChild(bitmap1);
var bmd2:BitmapData = new BitmapData(mySwf.width, mySwf.height, true, 0xFFFFFFFF);
var pt:Point = new Point(0, 0);
var rect:Rectangle = new Rectangle(0, 0, mySwf.width, mySwf.height);
var threshold:uint = 0xFF999999;
var color:uint = 0xFFFFFF00;
var maskColor:uint = 0x00FF0000;
bmd2.threshold(bmd1, rect, pt, ">=", threshold, color, maskColor, true);

var bmd3:BitmapData = new BitmapData(mySwf.width, mySwf.height, true, 0xFFFFFFFF);
threshold = 0xFF000000;
color = 0xFF00CCCC;
maskColor = 0xFFFFFF00;
bmd3.threshold(bmd2, rect, pt, "==", threshold, color, maskColor, true);

var bitmap2:Bitmap = new Bitmap(bmd3);
bitmap2.name="dup";
bitmap2.x = bitmap1.x + bitmap1.width + 10;
if (map.getChildByName("dup") != null){
map.removeChild(map.getChildByName("dup"));
}
map.addChild(bitmap2);
}
]]>
</mx:Script>
<mx:Canvas id="myCan" x="10" y="10" width="650" height="603">
<mx:SWFLoader id="mySwf" width="100" height="250" horizontalCenter="0" verticalCenter="-7.5" source="dance.swf" complete="init()" scaleContent="false" autoLoad="true"/>
<mx:Image x="61" y="320" width="550" height="152" id="map"/>
</mx:Canvas>
</mx:Application>
It works quite fine but I afraid that it's quite resource consuming using enterframe and bitmap drawing. Is there any better method?
Thanks for help.

How Would I Go Changing Lots Of Movieclips Color And Border Color Seperatly?
I am in the making of a isometric level editor, and I have about 15 movie clips with more to come.
I want to let people change the color of tiles to what they want from a list of colors, so how can I let them change the color of a tile dinamicly with actionscript so that it changes a tile's color while preserving changes of "shadows"?
I mean I have let's say a cube and to make it look 3D I need to change each face to make a feeling of 3D and not a flat one.
thanks.

Changing Color On RollOut Then Back To Color After 2 Seconds
I am using the code below to make a shape turn color using on rollOver, then on rollOut is changes to a differant color(blue), then I want it to change back to the first color(white), either on another rollover or I perfer to make it change back to the fist color after a 2 seconds,

on (rollOver) {
var colorful = new Color("_root.shapes");
colorful.setRGB(0x006699);
}
on (rollOut) {
var colorful = new Color("_root.shapes");
colorful.setRGB(0x006688);


I want to be able to rollOver change color, onRollOut Change color again, then back to the first static color after 2 seconds.
Anyhelp would be great Thanks

[CS3] Changing Color (and Opacity Of That Color) Of Movie Clip
Hi. I have a pretty large movie clip filled with pngs. It's a sprite for a game and I want to change it's color. The setRGB method works, but I can't figure out how to set the opacity of the color. I don't want to change the alpha of the movie clip itself, just the color I'm applying to it so that it's just a shade over the normal images.

Is there any way to do this?

Changing Stage Color When Changing From Scene
Hi,
I would like to change the color of my stage when I get in my next scene, is it possible?

So when people look to the movie Scene one should be black and scene 2 white. Don't tell me to put a big white square at the button of scene 2 coz when put it online I want all my window to change from color.

Thx

Change Color For More Mcs With Color Object At A Time
This changes color of one mc:

Code:
myColor = new Color(myMovie);
myColor.setRGB(0x993366);


Is there a way if I have dozen of mcs to change color at a time for all this mcs?

Thank you

[F8] Color Swatch Or Change - Color Object?
You know how on retail sites or even a car site you can swap the color by clicking on the swatch and than the image changes the color. I wanted to do this in flash preferably with actionscripting but I have NO CLUE how to do it. Can anyone show me a tutorial or advise me o how to do this. This is just a BASIC example in flash five but this is the same concept I want. http://www.adobe.com/support/flash/i...y/colorobject/ If anyone knows of a high level example with tutorial I would appreciate it.

Turtle

Change Color For More Mcs With Color Object At A Time
This changes color of one mc:

Code:
myColor = new Color(myMovie);
myColor.setRGB(0x993366);
Is there a way if I have dozen of mcs to change color at a time for all this mcs?

Thank you

Setting The Color Of Multiple MCs Using One Color Object
Hiya I am making a movie that has to be published to Flash Player 6 and want to set a bunch of movie clips to have the same color. Here is my function:

ActionScript Code:
var fillObjs_ar:Array = [square_mc, circle_mc];function colours(array:Array, color) {       for (i=0; i<array.length; i++) {        var my_color:Color = new Color(array[i]);        my_color.setRGB(0x+color);    }}colours(fillObjs_ar, FF0000);

My problem is that I get the error message:
"Hexadecimal digits expected after 0x" referring to the 4th line of my function.
If anyone could help me out it would be really appreciated.
Thanks
Schm

Change Color For More Mcs With Color Object At A Time
This changes color of one mc:
Code:

myColor = new Color(myMovie);
myColor.setRGB(0x993366);

Is there a way if I have dozen of mcs to change color at a time for all this mcs?

Thank you

[F8] Problem With Changing "Shape Fill Color" Color
Hi guys,

I am having some trouble trying to figure out how to change the Shape Fill Color for the corner which is currently in #FF6600.

Can someone advise me how I can access this attribute?

See files attached.

Hex Color As Variable In Color Object?
im trying to do this

myColor = new Color(myMC);

myColor.setRGB(variable);

we have all of the colors we need in css info in a database but im attempting to use the same values in flash. i can load the variables in fine but when i try to set them as a hex color it just assumes the letters are hex colors.

any suggestions

Background Color With Color Object?
Hey guys, quick question, is there a way to control the background color of a flash movie using the color object or some other way? i would like the entire window (html background included) to change, so sticking a stage-size movieclip in the back wouldn't help. Thanks .

Color Changing
Hi all,

i created a movie clip, in it's time line i put the action to rotare random 360 degree, it is working fine, like that i need to change the color of this movie randomly (RGB values 255).

thanks a lot for your replay.

naushad

Changing The Color Of A MC
Ok I hope that I can explain what Im after. I would like to make the color of a MC change (Morph) to the next closest value. Like gradually changing. Not just from RED to GREEN but more like red to reder to redest to dark red and so on. I hope someone can help..

Changing The Color On MC
ok i have found a script that will change the color of the MC gradually. BUT, I want it to change the R from 0 -255 then stop and staret to change the G from 0 - 255 And so on. What I have now is setting all the VAR to change the RGB al at once. Here is the code.


onClipEvent(load) {
colorFace = new Color(this);
var cnRedStart = 50;
var cnGtreenStart = 115;
var cnBlueStart = 152;
var cnRedRange = 150;
var cnGreenRange = 116;
var cnBlueRange = 80;
var i = 0;
var ldir = 0;
_root.lPlaying = 1;
}

onClipEvent(enterFrame) {
if (_root.lPlaying) {
nRedSkin = cnRedStart+(i*.01)*cnRedRange;
nGreenSkin = cnGreenStart+(i*.01)*cnGreenRange;
nBlueSkin = cnBlueStart+(i*.01)*cnBlueRange;
i = (ldir==0 ? i+1 : i-1);

colorFace.setRGB(nRedSkin<<16 | nGreenSkin<<8 | nBlueSkin);
}
}
What I want is to controll the colors one at a time not all at once.

Changing Color, Please Help...
hi,

i have a movieclip that consists of two other movie clips. i'm trying to change the color of the one sub-movie clip(sub_mc1), when you clicked on the main movie clip. the color is being decided by a variable ( _root.color ). i tried this code but it dosen't work...

onClipEvent (mouseUp) {
c = new Color( this.sub_mc1);
c.setRGB( parseInt( _root.color, 16 ) );
}

but this code changes the main movie clip's color, but when you click enywhere (i want only on movie clip) :

onClipEvent (mouseUp) {
c = new Color( this );
c.setRGB( parseInt( _root.color, 16 ) );
}

what is wrong with the firs one ??? please help...

Copyright © 2005-08 www.BigResource.com, All rights reserved