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




Changing Colour Using Actionscript?



I have a dentist client who needs a flash component for a site that allows the user to change the colour of individual braces on an illustration.

Obviously I can make each brace a movie clip and create a frame for each possible colour. But is there any fast/easier way to do this?

The main problem is that there are about 40 possible colours and you need to be able to apply a chosen colour to individual teeth, all teeth, top or bottom rows, odds or evens.

Thanks



KirupaForum > Flash > Flash 8 (and earlier) > Flash MX
Posted on: 10-05-2003, 01:38 PM


View Complete Forum Thread with Replies

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

Colour Changing With Actionscript
I have a movie that will sequence other Flash movies that it reads in from the directory. What I want is an option for the user to change the background colour of the movie. Is this possible using actionscript? If not, could I put a MC that would cover the background of my movie and then change the colour of that?

Thanks for your time

Changing Colour Via Actionscript
can you change the colour of text or an object via actionscript?

thanks in advance

Changing Colour Using Actionscript?
I have a dentist client who needs a flash component for a site that allows the user to change the colour of individual braces on an illustration.

Obviously I can make each brace a movie clip and create a frame for each possible colour. But is there any fast/easier way to do this?

The main problem is that there are about 40 possible colours and you need to be able to apply a chosen colour to individual teeth, all teeth, top or bottom rows, odds or evens.

Thanks

Changing Colour With Actionscript?
Hi,

I have a menu made with AS 2.0 that gets its values from an xml file, its a collapsable menu and I want the secondary nav (or sub nav) not only to indent but to be a different colour?

Heres the code I'm trying to alter-



Code:
TextFieldClass.prototype.drawText = function(newName, x, y, w, h) {
// ---set unique depth to attach at
++this.depth;
// ---basic MX create blank textfield method
this.tempText = this.createTextField(newName, this.depth, x, y, w, h);
// ---link between new textfield and parent Object
this.tempText.parent = this;
// ---set textfield type: "dynamic" or "static" or "input"
this.tempText.type = this.fieldType ? this.fieldType : "dynamic";
// ---allow cursor selection of text
this.tempText.selectable = false;
// ---specify HTML text
this.tempText.htmlText = this.title;
// ---control textfield background colour
if (this.applyBground) {
this.tempText.background = false;
// ---background colour matches button background colour
this.tempText.backgroundColor = parseInt(this.blurColour);
// ---would only apply if textfield was "input" type and selectable
if (this.applyFocus) {
this.tempText.onSetFocus = this.handleFieldFocus;
this.tempText.onKillFocus = this.handleFieldBlur;
}
}
// ---embed fonts for antialiasing
// this.tempText.embedFonts = true;
// ---specify password type textfield
this.tempText.embedFonts = true;
if (this.protect) {
this.tempText.password = true;
}
// ---define appearance of textfield content
this.styleObj = new TextFormat();
this.styleObj.font = "Helvetica Neue";
this.styleObj.size = 12;
this.styleObj.bold = true;
this.styleObj.leading = -30;
// if this is a secondary button, indent by 5 pixels
this.styleObj.indent = this.applyindent ? 15 : 5;
// ---apply style to textfield
this.tempText.setTextFormat(this.styleObj);
};
// ---[method] changes textfield background colour on focus
TextFieldClass.prototype.handleFieldFocus = function() {
this.backgroundColor = this.parent.focusColour;
};
// ---[method] changes textfield background colour on blur
TextFieldClass.prototype.handleFieldBlur = function() {
this.backgroundColor = this.parent.blurColour;
};
// ---test whether textfield contains text, returns a boolean
TextFieldClass.prototype.isEmpty = function() {
if (this.txt.text == "") {
return (true);
break;
}
return (false);
};

It says that he uses this code to indent the sub nav-


Code:
// if this is a secondary button, indent by 5 pixels
this.styleObj.indent = this.applyindent ? 15 : 5;
so I've tried similar things to that but with colour specifications instead but still no luck, any ideas? Its probably pretty simple but I can't seem to get it to work?

Changing Colour With Actionscript?
Hi everyone,

I have an xml driven menu which I've downloaded, in the code theres a section which tells the submenu to be indented my 5 pixels and I was wondering if there was a way to tell it to make the sub menu grey too?

Here are the two bits of the code that I think make the indent (from different parts of the component)-



Code:
CollapseButtonClass.prototype.init = function() {
if (!this.alpha) {
this.alpha = {start:25, top:100, bottom:25};
}
this.yinactive = this._y;
this.y = this.yinactive;
this.bgObjParams = {width:this.parent._width_, height:this.parent._height_, colour:(this.butType == 'secondary') ? (this.parent.sColour) : (this.parent.pColour), alpha:this.alpha.bottom, resize:false, applyColour:true};
this.txtObjParams = {x:3, y:3, w:this.parent._width_ - 20, h:this.parent._height_ - 5, resize:false, applyBground:false, applyFocus:true, title:String(this._name), applyIndent:(this.butType == 'secondary') ? (true) : (false)};
this.id = this.attachMovie("Rectangle", "bg", 1, this.bgObjParams);
this.id = this.attachMovie("TextBox", "txt", 2, this.txtObjParams);
this.id = this.attachMovie("Rectangle", "bg", 1, this.bgObjParams);
this.id = this.attachMovie("TextBox", "txt", 2, this.txtObjParams);
this.active = false;
this.enabled = true;
};
CollapseButtonClass.prototype.onSignal = function() {
if (this.enabled) {
if (!this.active) {
this.butType == 'secondary' ? this.bg.setColour(this.parent.sColour) : this.bg.setColour(this.parent.pColour);
var newOpacity = Mouse.isWithin(this, true) ? this.alpha.top : this.alpha.bottom;
this.bg._alpha = Math.approach(this.bg._alpha, newOpacity);
} else {
this.bg.setColour(this.parent.aColour);
}

if (this._y <> this.y) {
this._y = Math.approach(this._y, this.y);
}
}
};

and the second bit-



Code:
// ---define appearance of textfield content
this.styleObj = new TextFormat();
this.styleObj.font = "Helvetica Neue";
this.styleObj.size = 12;
this.styleObj.bold = true;
this.styleObj.leading = 0;
// if this is a secondary button, indent by 5 pixels
this.styleObj.indent = this.applyindent ? 15 : 5;
// ---apply style to textfield
this.tempText.setTextFormat(this.styleObj);
};
Any ideas anyone?

Thanks,
Tom

Colour Changing Using Actionscript
Hi. This is my first post in Kirupa so bare with me if I suck at this.

MY GOAL: I have a 1 colour city skyline image that I am using for the basis for a flash website. 6 of the buildings in the skyline are links to separate pages. Each of those buildings are the same colour as the main image but have a black rollover state. I have used a script to change the colour of the image that is located inside the movie clip but need by buttons that are also located inside my main movie clip to still have a black over state when a different colour is chosen.

IN DETAIL: I have utilized a Kirupa tutorial named Changing Colours Using Actionscript. In manipulating it for what I need in the website I am creating, I have an issue that needs urgent attention.

I have created the movie clip "main" that changes colour on click which is fine. Inside that "main" movie clip I have 6 or so links on a different layer that also change colour with with the rest if the movie clip. They are all set to have an overstate of "black".

When I test the movie, without changing the colour first, my links still have an over state of black that I pre-assigned to all the links. However, after I have selected to change the colour of the "main" movie clip, all the over states of my buttons change as well. I tried to give each button its own script as per the tutorial but it doesn't work.

1. Does anybody have any ideas how I can get around this issue?

2. If so, I also need to know how to set the images back to it's original colour?

Thanks

Changing The Background Colour WITHOUT Actionscript...
You can probably do this a little bit easier.

When you create another scene simply duplicate the original and remove all of the frames save the last one in the first scene. From here you can create a transitional effect.

Changing the background colour:

Add a layer that is at the bottom ( depth wise )of your movie. Use the rectangle tool to cover the entire area of the canvas.

Hide all the other layers and select the entire rectangle ( border and fill ) convert it to a graphic...edit the colours accordingly.

Then it's only a matter of adding a motion tween using the "tint" operator in the properties panel...

Regards,

1beb


heh... I made a boo boo replying to this post I posted new instead of replying

Changing The Stage Colour Using Actionscript
is it possible to change the stage colour using actionscript and if so how? Please help i have tried a number of ideas but none seem to work.

[MX] Changing Background Colour Using Actionscript?
Hey guys

Im trying to make a little intro for a flash website. I was wondering if theirs any actionscript that allows me to change the background colour of a flash movie.

Changing Colour Of Movie Clips Via Actionscript
I am currently designing a portfolio site featuring various info sections set against identically sized and positioned, different coloured background boxes. As you move from one section to another I am trying to acheieve a smooth colour transition no matter what section you are moving from and to. I am trying to use an 'on click' action on a button to change the colour properties of a background box(which I have made a movieclip). For various reasons I want to do it using actionscript rather than timeline tweening. I think it is a 'set property' action but I can't make it work. Can anyone point me in the direction of a good tutorial for achieving this?
Thank you very much for your help.
m

Changing The Bg Colour Of A Flash Site With Actionscript
hi, is there anyway to change the background colour of a flash site with actionscript. like when you press a button?

so, in this case http://www.cartoonfox.hostrocket.com/cartoonfox-v4.html when you press a button, the WHOLE of the red changes to what ever colour?


thanks.

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.

Problem With Changing The Colour Of Actionscript Text
Hi,

I have a problem changing the colour of text in a dynamic text box.

I have created a dynamic text field with the following text in it: jjj fff jjj fff.

I then have an input text box below it. The user has to type the letters it sees in the text box above. If the user types a j the text in the textfield turns green, to indicate that the user entered the correct letter, if the user inputs the incorrect letter in comparison with the text above the text above (e.g: turns red.).

I want to program the text in the text field so that only the letter that they were supposed to type turns either green or red, depending on whether they typed the correct letter in the input box.

For example. if the user inputs a 'j' in the input box, the first j in the text field above, will turn to green, then if the user types in an f, the j in the text field above will turn to red, as the user was supposed to type a 'j'.

How can i control each letter colour of the textfield.

Any help would be appreciated.

From a confused programmer.

Clodagh2000

[Flash8] Changing The Colour Of Text Using Actionscript
I'm trying to create a crossword puzzle, and I was wondering whether its would be possible to change its colour if the letter was right. For example if the right answer was C and C is entered in the box the letter goes green or something similar.

Any help would be much appreciated

Changing The Bg Colour Of A Flash Site With Actionscript
hi, is there anyway to change the background colour of a flash site with actionscript. like when you press a button?

so, in this case http://www.cartoonfox.hostrocket.com/cartoonfox-v4.html when you press a button, the WHOLE of the red changes to what ever colour?


thanks.

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 Colour
Can anyone tell me how I can gradually change the colour of a clip from one colour to another using A/S? I need to be able to calculate the hex values in a series of steps from one to the other.

Any help will be much appreciated

Thanks

Colour Changing
hi all,
I have three buttons and one rectangle which is blue, when button 2 is pressed I want the rectangle to fade to red and when button 3 is pressed the rectangle to fade to green...and so fourth
thanks,
tom

Colour Changing
I can change the colour of a movie clip by clicking on a button but how do I program it to continually change colours through the spectrum e.g. yellow through to blue, preferably fading in each colour, say every five seconds?
Please see my attached fla.

Changing The Colour Of An Mc
hey

can you use AS to change the fill colour of an MC, say i've got a square with a red fill colour and a black outline...can you change the red fill to white when someone clicks on it, no fading or anything just simply change colour..

thanks

Changing The Colour....
I found this last year and i just remembered just then in a spur of the moment type thing..... when I was studying for my exams for in year 10, there was a test that you could do and in was done in flash obviously.... and they had changed the colours of the scroll bar that you get with Flash MX 2004....

How do you do that without adding a alpha channelled colour over the top of it?


MAKEitLOUD.

[MX] Changing Colour
Hi

I need help, I got this code from Kax. This allows me to change colour of my background. This use to work on my movie but now is just not working anymore!

Since i created a button loading a .swf file this has stopped working, Any suggestions anyone?

Code is below

on (release) {
MovieClip.prototype.fadeColor = function(cto, e) {
var myColor = new Color(this), cColor = myColor.getTransform();
this.onEnterFrame = function() {
for (var c in cColor) {
cColor[c] += (cto[c]-cColor[c])/e;
}
myColor.setTransform(cColor);
};
};
myMovieClip.fadeColor({rb:204, gb:0, bb:0, ab:255}, 4);
}

I understand that I have to replace "myMovieClip" with the name of my clip!

Hope someone can help!!!

Changing The Colour Of An Mc
hey

can you use AS to change the fill colour of an MC, say i've got a square with a red fill colour and a black outline...can you change the red fill to white when someone clicks on it, no fading or anything just simply change colour..

thanks

Changing Variable Colour?
Is it possible to chage the colour of a variable and even better parts of it!

for example can the variable text read

hello (in blue) this place is (in black) GREAT! (in red)

then have it changed to

hello (in red) this place is (in blue) GREAT!! (in black)

it was just something i was thinking of and thought it could only be done in AS.

Thanks people!!

Danny

Changing Colour Of A Movieclip
Hi.

I am wanting to change the colour of a movie clip which I have in mt flash. At the moment it is completely empty with no symbols in etc. Can anyone suggest what I need to do in order to change the colour of this clip using actionscript?

If so what code will I need to use and will I need to make any changes to the MC in order for it to change colour.

Thanks

Immy

Changing Background Colour
Does anyone know how to change the background colour using Action Script. I have several scenes but want to change the background colour for each.

Any help appreciatend.

Dynamic Colour Changing
Okay, is there anyone out there not knows the basic syntax to change the colour of an MC?

Lets just say i declare these variables from an outside source...
_global.myRollOver = 10;
_global.myRollOut = 25;
_global.myColour = 0xFF00FF;

then, i call them on the MC....

on (rollOver) {
this._alpha = myRollOver;
}

etc...

now i want to do the same with the colour... can anyone help me out with this?

Changing Instance Colour
How can I change an instance of movie clip without actually changing the movie clip?
...Im sure its very easy if you know how.

Colour Changing By Buttons
hi all,
I have three buttons and one rectangle which is blue, when button 2 is pressed I want the rectangle to fade to red and when button 3 is pressed the rectangle to fade to green...and so fourth
thanks,
tom

Changing The Colour Of A MC With Buttons
Ok, I am only a beginner so be gentle and dont moan if this has been asked many times before. I have a movieclip which is a black square and instance name bigblacksquare. I then have 4 buttons called bluechangingbutton , redchangingbutton , greychangingbutton and greenchangingbutton . I want these buttons to change the colour of the square.
What code will be needed for each button, the movieclip and the first frame of the movie.
Any help will be greatly appreciated.

Changing Colour Of Xml Text
I have an .xml file loading into a dynamic text box. Can I change the colour of the font in the .xml file so I can have red or black text so that:
<Slides>
<slideNode jpegURL="images/image1.jpg">This text is red,
and this text is black</slideNode>
<slideNode jpegURL="images/image2.jpg">This text is red,</slideNode>
<slideNode jpegURL="images/image3.jpg">this text is black</slideNode>
<slideNode jpegURL="images/image4.jpg">This text is red,</slideNode>
<slideNode jpegURL="images/image5.jpg">this text is black</slideNode>
</Slides>
Hope that's clear, mainly having different colour text than spacified in the flash text box.

Changing The Background Colour
Hi,

I am using Flash MX, How do you change the BG colour of the document when entering a certain frame?

Buttons Changing The Colour After Use?
Hi all,
I wondered if someone on here could tell me how to make a button change colour after use in flash mx. Letting the user know they have already cliked that button.


Hope Ive explained myself clearly thanks

Paul

Colour Changing Sites
Hi there
Have a look here: http://mecano.ca/flash.php

Did this guy really create a site with 5 different colours or did he plug some code in there to change the colours based on what button you click?

Changing Font Colour
i have black text n i want, when the user moves the cursor over the ext, for the text to slowily turn red. how wuld i do that? i tried tinting the buttons to red n then add motion tween but it didn't work. hepl plz!

Shapeflag Way Of Changing Colour?
I was wondering if there was a way to put a semi-transparent mc over a bitmap graphic or just another mc, so it would change a little bit the mc's color or hue, if you get what I mean.

I know that it's (at this point,) possible and easy to do, but I would like to know a way to change the color of each points in the movieclip, that ARE NON-TRANSPARENT, just the way the shapeflag hitTest does.

Hope you can help me out.

Changing The Colour Of The <li> Points?
flash automatically inserts a black bullet point, can the colour be changed? I've tried everything!

Changing Text Colour
Hi,

I'm sure this is simple, but I can't get it to work, I just need to set the colour of the text in a textfield, i've tried things like text.color = 0xff0000; with "text" being the textfields instance name, but it doesn't work, do I have to create a color object?

thanks for any help.
boombanguk

Changing HighLight Colour
Hi,

I've got a website that I'm using scroll panes in to dynamically call in other movieclips that hold info with text and graphics that the user can scroll through.

So far so groovy, I've skinned it and it looks great and works great.

Now the prob. When it's clicked on I get the halo green border around the component. It looks awful - I'm not even a fluffy designer and I don't like it - please - if you know how to turn off the higlighting or at least change it's colour I'd appreciate any help.

I have gone through the theme with and can't find it anywhere.

I'm sure the solution is action script - but I can't find the right call on the Macromedia site, in the help or just by hacking around with code and changing the styles.

On another similar but slightly different point.

WHY OH WHY do we not have a place where the style properties for each component are listed with the action script calls? Surely it can't be too hard for Marcromedia to put a simple list like this together. Instead you find yourself going from page to page to page in the help or live docs in this case starting with the Scroll Pane - then going to the Scroll Bar - then going to the RectBorder Class - then going back to the Scroll Pane - then etc etc. I can't be the only one getting extreamly fed up with this massive waste of time just to find the right code to change a colour?

Sorry rant over - However I would be interested in collaborating with anyone who would like to set up a simple list such as the one I just talked about.

Back to the prob - how do I turn off the highlighting of the ScrollPane, or change it's colour? Help!!!!!

Cheers

Tim

Changing Colour Question
I am trying to get a status bar to change colour when it hits the halfway point. The bar goes up when it colides with the player but it won't do anything but go up and down.

THis is the code that I have, both if statements work but the colour changing code does nothing.


Code:
if (_root.player_mc.hitTest(_root.t))
{
loadBar_mc._height--;
}
if (loadBar_mc._height>30)
{
var colorful = new Color("_root.loadBar_mc");
colorful.setRGB(0xFF0000);
}

Changing Background Colour
Hi Guys,

I'm fairly new to flash.

I am making a webpage, and am using flash to do it.
So far it is very simple. I have some text layers which move the playhead to different points in the timeline, using the actionscript goto...

I want to know if it is possible to have the background colour fade to different colours independant of where the playheaad is in the timeline?

Any ideas?

Thanks

AT

Changing Colour And Size
I have a very easy question about changing the colour and shape of an object using action scripting. I've created a slider and activated control of the size using action script attached and I just need to know what script to add to make it change colour as it slides as well. Can anyone help me. Thanks







Attach Code

shape.targetWidth = shape._width;
shape.targetHeight = shape._height;

shape.onEnterFrame = function() {
var speed = 5;
this._width += (this.targetWidth - this._width)/speed;
this._height += (this.targetHeight - this._height)/speed;
};

Changing The Colour Of An Image
I have a client that has a series of products that come in different colours and different textures. What I need to do is have picture of the product. When the user runs a mouse over the colour palette the product changes it's colour to represent the chose made by the customer fro the various choose in a colour palette. Ford Canada does this when I pick the colour of my car. I can run over red and the car will change colour to red.

Just wondering how this is done

Changing The The Colour Of The Focusrect
Hi,

Does anybody know how to change the colour of the focus rectangle?

Cheers

SHO

Changing A Sybomls Colour
If I have a block thats say red. How do I change its colour to blue or green etc. . I want this to happen when I click a button. Say i gave my bloack the intance name "block" would I start my actionscript someithing like:

block.onRelease function( .....

and have it effect the alpha channels?

Changing Text Colour
I can't seem to do this effect for some reason. If you go to http://www.energypixel.com/ when the red thing goes over the menu links (which are grey color), the links turn white with the red bar over it so you can see the text easier. How did he do this effect. It won't change for me, or it's a pain.

Changing Colour Of Movieclip
I have this piece of actionscript working


ActionScript Code:
var my_color = new Color("mymc");my_color.setRGB(0xFF0000);



This works when I call the actionscript say from a button on the same timeline as the movieclip. What I can't get my head round is how I change the colour of an object on a different timeline, say if the path to the movieclip was _root.mc1.mc2.mymc

What would be the actionscript then?

Changing Background Colour...
im trying to change background colour

var color:Color = new Color("stage");

color.setRGB(0x000000);

its currently purple, how come it doesnt change

Changing The The Colour Of The Focusrect
Hi,

Does anybody know how to change the colour of the focus rectangle?

Cheers

SHO

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