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.
KirupaForum > Flash > ActionScript 3.0
Posted on: 10-30-2007, 07:32 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
[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.
Changing Color Dynamicly
Hi all,
I got a map of The Netherlands divided into zipcode areas. I want to create a rollOver that works for all mc's (where each area is a different mc).
I've got this so far.
Code:
//Variabele active declareren:
active = 0;
//Hoeveel easing in de motion:
Ease = 6;
//Interval Variabele aanmaken
var nInterval:Number;
//Motion calculatie naar nieuwe positie
function calculation():Void {
mcArea._xscale += (endX-mcArea._xscale)/Ease;
mcArea._yscale += (endY-mcArea._yscale)/Ease;
}
//Button motion function zoom IN
//---------------------------------------
function activeFunction():Void {
endX = 120;
endY = 120;
calculation();
updateAfterEvent();
}
//Button motion function zoom OUT
//---------------------------------------
function inActiveFunction():Void {
endX = 100;
endY = 100;
calculation();
updateAfterEvent();
}
mc78.onRollOver = function():Void {
active = 78;
mcArea = this;
clearInterval(nInterval);
nInterval = setInterval(activeFunction, 30);
}
mc78.onRollOut = function():Void {
active = 0;
mcArea = this;
clearInterval(nInterval);
nInterval = setInterval(inActiveFunction, 30);
}
Now i do managed to change the scale of the MC number 78 (one of the areas), but i'm a little stuck on changing the color. How do i change the color of the MC('s) on rollOver?
Also any other suggestions on how to make it even easier would be much appreciated.
Thanks in advanced!
Changing Text Color Dynamicly?
Is there a way in F5, through ActioScript, to change the color of a font contained within a dynamic text field?
For instance, if I have on my stage a text field with a variable name of "link1", I'm wondering if I can on(rollOver)change my font color from say #999999 to #00FF00. Maybe through set property?????
Fill Color With Line Boundaries
What i need is the ability to "fill" an area of "color" in an imported image onto the stage to whatever color i need, and for it to fill the entire area until it reaches a boundary.
Now, if your as lost reading that as i was when i typed it, what i need is exactly what you have in mspaint (Microsoft Paint) basically i need my own paint bucket tool, so that i can fill an area of an imported image to whatever color i want.
I have played around with the BitmapData.threshold function, however whilst it works, if a user colors area1 blue, and then area 3 blue, then decides he really wants area 3 red, when he repaints area3 red, he will also paint area1 red too...
Threshold just works too well, i need to re-painting or "filling" to stop when it hits a border, and not change other parts of the image that are the same color.
An example of the image is located here: http://www.xavierit.com.au/lineDrawing.JPG i want the user to be able to paint individual cells any color they want, but i cannot find an approprate way of doing this.
Changing The Fill Color
Hey all,
what I want to do is to change the fill color of my shape depending on a variable. I have all the stuff out and everything is nice. I just don't know how to change the fill color of my shape to reflect this.
thanks a bunch!
Changing Text Fill Color...
I am trying to create an effect where you rollover a text, and the text changes color. I tried the "setTextAttr" Property, but I don't think I am using it correctly. Anyone got any tips?
Thanks a lot.
Changing Fill Color Of An MC By Clicking Button
I have an MC, a picture of a shirt. I also have a color chart (ie rows of little colored squares that are buttons). If i click one of the squares, lets say its green, how can i make the color of the shirt change to green? Is there a way to do this with ActionScript? If so, where would i put the necessary code?
Fill Color And Stroke Color Option Not Working...
I am a faculty member at American River College who needs a word or two on how Flash CS3 works.
Specifically, how do I get back the option to add fill color to an oval drawing that I have made in Flash CS3? It appears that I have flipped a setting that makes that seemingly simple option unavailable.
I have several other documents where I have added fill color without a problem; however, as of this morning CS3 will not allow me do add such. When I open Flash, I draw on the Stage, the outline color is usually green, no matter what color I select for as Stroke Color and Flash will not allow me to change the Fill Color. I make a selection and nothing happens (just moments ago I opted for red as the Fill Color and the Fill remains white).
Is there a setting in Flash, that a rookie like yours truly could activated by accident?
Please help.
MacBrowne
Changing Sprite Line Color Through AS
Hello,
Is it possible to smoothly change the color of the line in this sprite over a period of time?
Code:
var sp:Sprite = new Sprite();
addChild(sp);
sp.graphics.lineStyle(3, 0x31FF1A);
I saw a bit of code that used Tweener to do this with a movie clip, but I can't make Tweener work with a sprite.
-Beanpole136
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?
Change Color Dynamicly
Im desiging a nav for one of our web tools taht will be reused on many sites. we have color info for each of the sites in a db. what property do i need to set to change the color. i dont see anything under setProperty.
I'm assuming i should make each of them a MC
thanks
Fade Mc Color Dynamicly?
Trying to figure out how to make the color of an mc fade dynamicly from one color to another based on the color chosen.
color1 = 16776960;
color2 = 3407616;
make button change from color1 to color2;
Any ideas?
Loading Color Value Dynamicly
Hi, I'm curently working on a site loading all it's parameters and content from external files. I actually have a problem setting the background color for some items.
I use this method where I tried in many way to load the rgb value from my external text file:
Code:
myColor = new Color(main_txt.bg_main);
myColor.setRGB(0x566D96);
Actually the line "_root.:couleur_header = myLoadVar.couleur_header;" load the rgb value 566D96, if I test it standalone with a text field it loads the value properly. Then I try to load this value to my actionscript, I tried with or witouth the eval argument:
Code:
_root.:couleur_header = myLoadVar.couleur_header;
myColor = new Color(header_status.status_bg);
myColor.setRGB(eval("0x" add couleur_header));
Right now the result is a blank value and a black background.
Any suggestions how I could get it to work?
Fill The Color
Hi, I have problems in fill colour again, but this time is the background. I want to set some color to my background but it mix with my character (because some of the part of my character is trasparent.
What can I do?
Thanks
Fill Color In Cs3
hi--i've been using flash for a while now, but i seem to be encountering a glitch in cs3. either that or it's a brain glitch: when i type in a hex number in the fill color dropdown box, the new color does not take. it reverts back to the color indicated when i opened the fill color box. it's driving me mad. it does not matter whether or not i have an object selected. it also will not change in the properties window. help?
Fill Color
hi all, how to fill color to sometime u drew? like in the paint program that is..cus i did a flash function someting dat allow users to doodle around, but i wnana have a button when selected, user can click on the ting they drew n fill it with color. isit possible? thanks!!!
Fill Color
hi all, how to fill color to sometime u drew? like in the paint program that is..cus i did a flash function someting dat allow users to doodle around, but i wnana have a button when selected, user can click on the ting they drew n fill it with color. isit possible? thanks!!!
Can You Change The Color Of A Fill Only
Assuming you have a movieclip that contains a simple box with an outline and a fill, is there a way to change only the fill or only the outline color (using actionscript) without making the outline and fill into seperate clips?
Unable To Fill The Color
I have tried many times to fill my hat or face ,but still unsucceed. I havent lock it and have already change option to Close Large Gap.
I think there is some small gap in my picture so I cant fill it. Anyone helps?
Thanks
Background Color Fill?
I have seen people do a paint bucket fill for a background in flash with a multie colored fill. How do you do this? It is like white/brown/blue and then an image in the brown color. When I click on the background 1st it is a movie clip then a graphic then a shape. How do I do this?
Thanks
Dyanmic Color Fill
hey everyone, i am trying to create a character creator problem i come across is that I want the people to be able to say what colour skin they want etc etc now i already have the shape drawn in flash in the location _root.test.skin
how can i change the colour of the shape? so instead of it being pink it can be brown?
dont want to have to draw different shapes for each colour cause then the thing will be huge
many thanks for any help!
[F8] Color Fill A Dynamic PNG
I am creating a banner which dynamically loads a png image through xml, no problem yet. The question i have is,
Is there a way to color fill the loaded image?
for example i have an png of a man loaded in with it's transparency. I want it to first appear filled white so it looks like a silhoutte which then fades into the image?
any simple fills i apply to the MC just don't seem to do anything once the png has loaded.
Select Same Fill Color
Anyone know of a Flash plugin that will select the same fill color? I do a lot of drawing in Flash and it would be so quick to have this feature. I know Adobe Illustrator can do it.
Thanks for your help!
Fill Color Using Actionscript
hi guys,
How to do something like this:
ActionScript Code:
on(release){
myMc.color = red
}
i've tried:
ActionScript Code:
on(release){
myMc.color = "#FF0000"
}
but it didn't work!
Auto Color Fill
Thanks to Inhan I can now do colorTransform. This question might be getting ahead of myself, but I was curious.
I've got something where users drag a color (MC) into a space (another MC) and the space becomes the color of the dragged MC. It's like a coloring book of sorts.
Now when the two MCs have a hitTest the color simply changes instantly. I thought it would be a cool effect if the color gradually filled the space like paint poured on the floor. I am thinking of a slow way where the dragged MC locks into the center position and then shape tweens into a preset fixed area, but I thought there might be some way to detect the shape it's in and just slowly fill that area.
I have a headache just thinking about this.
Thanks.
Select Same Color Fill
I draw a lot in Flash and it would really help if I could select the same color fill all at once. Right now I have to click on all the colors individually. I know Illustrator is capable of this. Does anyone know of a plugin that does this?
Thanks,
Andy
Fill Color In Movieclip
with (myClip) {
moveTo(0,0);
lineTo(50,0);
lineTo(50,100);
lineTo(0,100);
lineTo(0,0);
}
this creates shape which is empty .
I want to fill the shape created after i have set a certain parameter to
true. How to do that with movieclip.
beginFill not usable since it starts filling just from begining.
Color Fill Question
How do I flip the linear color fill so instead of going left to right it goes top to bottom?
Color Fill Png Dynamically?
Hi,
Didn't now where to put this, but AS3 looked like the best option.
So I'm developping a product configurator in Flex, and at a certain point the end -user should be able to "drag" a color to the product.
The product outlines are all dynamic loaded png's.
Now my question is how can I color fill these png?
With an underlaying sprite that i fill with a color is an option. But i've heard it's possible to use the png outlines as vectors, is it (maybe CS3 only)?
Thx!
Adding A Fill Color
i created a shape and i'm trying to add fill color to it, but it doesn't seem to work!
i drew the shape on layer2 and then selected the paintbucket tool and then my fill color and clicked the inside of my shape... but nothing is happening.
please help... it's driving me mad!
Color Picker And Fill Tool
i need a help..
i want to pick color and set color in drawings..
there is a color pallete, i want to click and get the value in a variable and i have defferent mc, when i click on some mc, the mc should get the previously chossen collor...
please help...
Choosing Gradients As A Fill Color
Hi.
I want to make an oval that fades from yellow on the inside to transparent on the outside. When I try to choose a gradient as a fill color in Flash, I only get certain options.. i.e. from red to black.. from white to black, from green to black, from blue to black, etc.
How do I customize my own gradients?
Thanks,
~j
Color Fill In Real Time?
Hi,
I've been looking at a post made, using some action script that will target a movie and fill the color according to to the color of your choice.....the problem i'm having is that i want to fill an image, but i want the image to retain it's original shading (so it still looks 3D without just completely filling it with one shade!!)
Is there any way of doing this??
Dynamic Color With Gradient Fill
Hi there,
I'm trying to figure out how to use dynamic colors within a gradient fill. This borrowed script works fine with hex colours, however when I use a dynamic field in there it doesn't take (line 2). It seems to not like the square brackets -the line style (a few lines down), has no problem taking the dynamic field. Any help would be appreciated..
Thanks
fillType = "linear";
colors = [_root.rollcolour,0x0000FF, 0x0000FF];
alphas = [75, 100, 25];
ratios = [50, 100, 200];
matrix = {matrixType:"box", x:200, y:150, w:150, h:100, r:0/180*Math.PI};
_root.lineStyle(0, _root.rollcolour, 100);
_root.beginGradientFill(fillType, colors, alphas, ratios, matrix);
_root.moveTo(200, 100);
_root.lineTo(350, 100);
_root.lineTo(350, 200);
_root.lineTo(200, 200);
_root.lineTo(200, 100);
_root.endFill();
How To Modify Outline OR Fill Color?
Is it possible with AS to change outline OR fill color?
I need somehow to highlight selected movieClip. But colors used in each particular movieClip can vary (as well as the background environment), so using colorTransformFilter on the entire movieClip instance does not work as needed.
Adjusting outline and fill color separately would help. Is there a way to achieve that at runtime?
Yaroukh
The Dynamic Color Fill Not Working For Me ?
i have the attachment
it suppose to fill the color to the position i mentioned ?
why the beginFill not working for me?
ActionScript Code:
var hor:Number;
var ver:Number;
var holder:MovieClip = _root.createEmptyMovieClip("holder",5000);
var count:Number =1;
selector = 0;
tile();
/////////////////////////////////////////////////////////////////////////////////////////
function drawline ()
{
// the below method not working for me?
// it suppose to fill colour after drawing a shape but its not happening
holder.beginFill(0xFFFF00);
holder.lineStyle(1,0);
holder.moveTo(newx,newy);
holder.lineTo(originx, originy);
holder.endFill();
tile();
originx = newx ;
originy = newy ;
}
// dot placement///
function tile() {
tile_width = 30;
tile_height =30;
//
x_max = 12;
y_max = 12;
for (x=1; x<x_max; x++) {
for (y=1; y<y_max; y++) {
s = _root.attachMovie("sprite", "s"+x+y, this.getNextHighestDepth());
trace(s11._x);
s._x = tile_width*x;
s._y = tile_height*y;
}
}
}
//// mouse position selector/////
for( count=1; count < 101 ; count++) {
btName = "s" + String(count);
this[btName].onRelease = function () {
if (selector == 0) {
originx = this._x;
originy = this._y;
selector = 1;
}
else {
newx = this._x ;
newy = this._y ;
drawline();
}
}
}
Change Color Of Fill In Drawing API
hi,
can I change the color of a fill that I've added to a sprite using the drawing API? This is not working:
Code:
var sp:Sprite = new Sprite();
sp.graphics.beginFill(0xCCCCCC, 1 );
sp.graphics.drawRoundRect(0, 0, 60, 60, 10);
addChild(sp);
sp.addEventListener(MouseEvent.CLICK, changeColor);
function changeColor(e: MouseEvent):void{
//sp.graphics.clear();
sp.graphics.beginFill(0xFF0000, 1 );
sp.graphics.endFill();
//sp.graphics.drawRoundRect(0, 0, 60, 60, 10);
}
Isn't it possible or am I missing something?
thanks :-),
Jeff.
Change Fill Color On The Layer
Hi everyone:
I can't seem to be able to do the obvious I have a symbol (movie clip) in the library - let's call it Ball - that consists of two layers. One layer has the outlines and the other layer has the fill. The goal is to create the Ball dynamically with a certain fill color:
Code:
var ball:Ball = new Ball(0xff0000);
addChild(ball);
The movie clip symbol is linked to a class like this:
Code:
package
{
import flash.display.MovieClip;
import flash.geom.ColorTransform;
public class Ball extends MovieClip
{
function Ball(color:uint):void
{
var colorTransform:ColorTransform = this.transform.colorTransform;
colorTransform.color = color;
this.transform.colorTransform = colorTransform;
}
}
}
But my problem is that when the code above is run everything changes color (the outlines and the fill layer). What I need to know is how to do this ColorTransform on a specified layer only?
(Or maybe there's a better way to change the fill color of an object?)
Donīt Color A Word But Fill It With Bitmap
Hi!
I have once seen a tutorial on how to fill a word by bitmaps. I canīt find it now. I have a word, kind of a logotype that I want to stand out from the background. I know you can do a lot of things in flash8. I would appreciate any tips of tutorials on this subject.
Controlling Mc Fill Color Externally
I have a project that demands control of the fill color of a rectangle shaped mc externally. So the user would have the control to change the fill color of a movie clip by editing something externally, not having to edit the flash file. Is this possible?
|