我正在Flash Pro CS5中创建自定义应用,并且我设置了变量以记录对选项的更改。以下代码位于舞台的最顶层。
//Clothes Variables
var clothingType:String = "";
var gender:String = "Male";
var clothingSize:String = "Small";
var quantity:String = "1";
var design:String = "";
var colour1:String = "";
var colour2:String = "";
以下是设计var被分配为designList上的标记按钮的示例(单击最后一个按钮是显示的当前设计)
///// SET UP LIST BUTTONS
contentMain.addEventListener(MouseEvent.CLICK, listClick);
contentMain.buttonMode = true;
contentMain.ting_btn.ID = "ting";
contentMain.exco_btn.ID = "exco";
contentMain.post_btn.ID = "post";
contentMain.eddie_btn.ID = "eddie";
contentMain.pre_btn.ID = "pre";
contentMain.logo_btn.ID = "logo";
function listClick(e:MouseEvent):void
{
printer.gotoAndStop(e.target.ID);
MovieClip(root).design = (e.target.ID);
trace(e.target.ID);
}
我正在使用HEX值输出(动态文本框显示最后点击的样本HEX值)来控制此colour1和2值,if语句无效。以下所有代码都在Ink_mc中,MC包含所有Ink选项,并且每个设计都有单独的帧(6个设计有6个帧,每个都有自己的调色板,designMC和用于控制颜色变化的代码但是它们共享以下内容代码,因为它位于跨越所有6帧的图层上
if (hexValue.text = "02ADDB")
{
MovieClip(root).colour1 == "Light Blue";
}
if (hexValue.text == "067ABB")
{
MovieClip(root).colour1 = "Blue B";
}
if (hexValue.text == "06579E")
{
MovieClip(root).colour1 == "Ultra Blue";
}
if (hexValue.text == "34328A")
{
MovieClip(root).colour1 = "Purple";
}
if (hexValue.text == "FFF100")
{
MovieClip(root).colour1 = "Mid Yellow";
}
if (hexValue.text == "FFCF48")
{
MovieClip(root).colour1 = "Yellow R";
}
if (hexValue.text == "B1D392")
{
MovieClip(root).colour1 == "Mid Green";
}
if (hexValue.text == "1ABO65")
{
MovieClip(root).colour1 == "Green B";
}
if (hexValue.text == "FAA9A7")
{
MovieClip(root).colour1 == "Glow Pink";
}
if (hexValue.text == "F174A7")
{
MovieClip(root).colour1 == "Glow Red";
}
if (hexValue.text == "B83O8B")
{
MovieClip(root).colour1 == "Rose";
}
if (hexValue.text == "D41F2E")
{
MovieClip(root).colour1 == "Bright Red";
}
这是我的一个选色器
//set up a listener for color change events dispatched from the color picker
//see as function layer for function
Pre_pal1.addEventListener(ColorPicker.COLOR_CHANGE, handlePre1ColorChangeEvents);
Pre_pal2.addEventListener(ColorPicker.COLOR_CHANGE, handlePre2ColorChangeEvents);
//this function is called whenever the user clicks the palette to change colors
function handlePre1ColorChangeEvents(ev:Event):void {
//output the hex value to the screen
hexValue.text = ColorPicker(ev.currentTarget).webValue;
//output the RGB values to the screen
rValue.text = String(ColorPicker(ev.currentTarget).red);
gValue.text = String(ColorPicker(ev.currentTarget).green);
bValue.text = String(ColorPicker(ev.currentTarget).blue);
//change the colour of the ladybugs shell to the current palette color
ColorPicker(ev.currentTarget).transformToCurrentColor(Pre1);
}
//this function is called whenever the user clicks the palette to change colors
function handlePre2ColorChangeEvents(ev:Event):void {
//output the hex value to the screen
hexValue2.text = ColorPicker(ev.currentTarget).webValue;
//output the RGB values to the screen
rValue2.text = String(ColorPicker(ev.currentTarget).red);
gValue2.text = String(ColorPicker(ev.currentTarget).green);
bValue2.text = String(ColorPicker(ev.currentTarget).blue);
//change the colour of the ladybugs shell to the current palette color
ColorPicker(ev.currentTarget).transformToCurrentColor(Pre2);
}
请记住,我需要为colour1和colour2 vars做这个,我已经做了一个相同的HEX值显示(只有4个动态文本框显示每个值,HEX,rValue,gValue,bValue),名为hexValue2, rValue2等等。
所以我想找到一种方法来根据最后显示的Hex值设置的Color名称来设置变量。对不起,如果我以天真的方式解决这个问题,希望有一个简单的解决方案。
如果您想了解有关如何设置文件或其他任何内容的更多信息,请告诉我们, adam@one69a.com。
谢谢!