Click on the color button and write in textarea with this font color

Hello world

I want to do the following:

  • Click on a "red" button
  • write in the text box with a red font
  • Click the 'blue '.
  • write in the text with a font color blue box

Does not use this possible in flash 10 AS3?

I tried to use setTextFormat but the problem is that I have the text before inserting on this format.

Please someone tell me how to do?

Thank you very much in advance

Concerning

:

Import fl.controls.Button;
Import fl.controls.TextArea;
import flash.text.TextField;
import flash.events.MouseEvent;

var tf2:TextField = createTextField (100,100,200,22,true);

TF2.Type = "input";
TF2. Background = true;
TF2. BackgroundColor = 0 x 777777;
TF2. Width = 400;
TF2. Height = 200;
TF2.x = 100;
TF2.y = 100;

var df1:TextFormat = new TextFormat();
DF1. Bold = false;
DF1. Align = "center";
DF1. Color = 0xffffff;
DF1. Size = 14;
TF2.defaultTextFormat = df1;
TF2. Text = "[text]";
TF2.setTextFormat (df1, 0);

addChild (ta2);
TA2. Move (150,100);

TF2.addEventListener (Event.change, f);

function f(e:Event):void {}
TF2.setTextFormat(DF1,TF2.caretIndex-1);
}

var btn_Colour_Red:Button = new Button();
btn_Colour_Red.label = "Red";
btn_Colour_Red.addEventListener (MouseEvent.CLICK, btn_Colour_Red_Clicked);
btn_Colour_Red.setSize (40: 20);
btn_Colour_Red.move (350, 0);
addChild (btn_Colour_Red);

var btn_Colour_Blue:Button = new Button();
btn_Colour_Blue.label = "Blue";
btn_Colour_Blue.addEventListener (MouseEvent.CLICK, btn_Colour_Blue_Clicked);
btn_Colour_Blue.setSize (40: 20);
btn_Colour_Blue.move (250, 0);
addChild (btn_Colour_Blue);

function btn_Colour_Red_Clicked(e:MouseEvent) {}
   
DF1. Bold = false;
DF1. Align = "center";
DF1. Color = 0xFF0000;
DF1. Size = 14;
TA2. SetFocus();
internship. Focus = tf2;
}

function btn_Colour_Blue_Clicked(e:MouseEvent) {}
   
DF1. Bold = false;
DF1. Align = "center";
DF1. Color = 0x0000FF;
DF1. Size = 14;
TA2. SetFocus();
internship. Focus = tf2
}

function createTextField(x:Number,_y:Number,_width:Number,_height:Number,_border:Boolean):TextField {}
var result: TextField = new TextField();
result.x = x;
result.y = y;
result. Width = width;
result. Height = height;
result. Background = true;
result. Border = border;
addChild (result);
return the result;
}

Tags: Adobe Animate

Similar Questions

Maybe you are looking for