Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript, movieclip color change?

New Here ,
Apr 15, 2020 Apr 15, 2020

So I am attempting to change the color of a movie clip fill I have made, I saw a post (https://community.adobe.com/t5/animate/changing-color-of-a-movieclip-with-javascript/m-p/9497833?pag... and followed it however the .shape .graphic and _fill.style dont work I switched it out with _fillcolor however that doesnt seem to work either (No errors in console it just doesnt do anything)

 

Context: I drew out the shapes using the line tool and the filled them in to separate into movie clips using the paint bucket tool. Fill_Color is a variable that is set to a hex color code I specified earlier in the code. IE: "#FFFF00"

 

Code:

this.Page1.Turtle.Fill_Turtle_Bandana.addEventListener("click", Color_Bandana.bind(this));
function Color_Bandana()
{
this.Page1.Turtle.Fill_Turtle_Bandana._fillcolor = Fill_Color;
}

 

If you want to see the full set of code I made for my swatches section I have attached a .txt file with that section.

TOPICS
Code , How to , Other
288
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 17, 2020 Apr 17, 2020
LATEST

I have found a partial solution to my problem, it still has a few problems with it but I will post it just incase anyone else has similar issues and may or may not be able to find a way to correct the rest.
I wish I knew where I found the original code but I have long lost the link, it origated with a color symbol randomizer and then I took it studied it until I could somewhat understand how it works. My current limitation is I cant for the life of me figure out how to have multiple color filters applied.

this.stop();
this.InsertMCHere.addEventListener("click", Color_Change.bind(this));//When you click the movie clip it runs through the color commands
this.Change_Color.addEventListener("click", Changing_Color.bind(this));//When you click the change color button you activate prompts
var Color_Red = 255
var Color_Green = 255
var Color_Blue = 255

function Changing_Color()
{
	Color_Red = prompt("Pick your Red Value 0-255","0");
	Color_Green = prompt("Pick your Green Value 0-255", "0");
	Color_Blue = prompt("Pick your Blue Value 0-255","0");
}

function Color_Change()
{
	this.setColors = function()//Establishes and immediately defines setColors function
{
	var w = exportRoot.target.nominalBounds.width * exportRoot.target.scaleX;//Retrieves shape data for x axis?
	var h = exportRoot.target.nominalBounds.height * exportRoot.target.scaleY;//Retrieves shape data for y axis?
	var index = exportRoot.count % exportRoot.colors.length;//No clue
	var r = exportRoot.colors[index].r;//exports red value? to .colors function
	var g = exportRoot.colors[index].g;//exports green value? to .colors function
	var b = exportRoot.colors[index].b;//exports blue? to .colors function
	
	exportRoot.target.filters = [new createjs.ColorFilter(0, 0, 0, 1, r, g, b, 1)];//Initializes color filter
	exportRoot.target.cache(-w * .5, -h * .5, w * 1.5, h * 1.5);//Filters the area that you define "(x,y)(x,y)"
}
if (!this.hasStarted)
{
	this.colors =//Recieves the export root data that was indexed earlier
	[
		{r:Color_Red, g:Color_Green,  b:Color_Blue},
	];
	
	this.target = this.InsertMCHere; //Selected Movie Clip
	this.count = 0;
	this.hasStarted = true;
}

this.setColors();//Runs the set colors function


}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines