Copy link to clipboard
Copied
I want to assign one of three text formats to an array entry. Currently I am able to change the text in the text box, but not the color.
import flash.events.Event;
stop();
nav_mc.next_btn.addEventListener(MouseEvent.CLICK, onNext);
function onNext(e: MouseEvent): void {
nextFrame();
}
var g: TextFormat = new TextFormat();
g.font = "Arial";
g.size = 20;
g.color = 0x00FF00;
g.bold = true;
var b: TextFormat = new TextFormat();
b.font = "Arial";
b.size = 20;
b.color = 0x24BCFD;
b.bold = true;
var r: TextFormat = new TextFormat();
r.font = "Arial";
r.size = 20;
r.color = 0xFF0000;
r.bold = true;
var ClassTitles: Array = new Array(totalFrames); // An array that will hold the Class titles
this.addEventListener(Event.ENTER_FRAME, initializeSlide);
function initializeSlide(e: Event): void {
banner_mc.txtTop.text = ClassTitles[currentFrame];
banner_mc.txtBottom.text = ClassTitles[currentFrame];
//banner_mc.txtBottom.setTextFormat(r);
nav_mc.slideTotal.text = totalFrames;
nav_mc.slideLocation.text = this.currentFrame;
}
// my array
ClassTitles[1] = 'OFFICIAL';
ClassTitles[2] = 'PROPRIETARY';
ClassTitles[3] = 'RELEASABLE';
ClassTitles[4] = 'OFFICIAL';
ClassTitles[5] = 'OFFICIAL';
ClassTitles[6] = RELEASABLE';
ClassTitles[7] = 'RELEASABLE';
ClassTitles[8] = 'OFFICIAL';
////What I would like to do to assign color to array or something similar
ClassTitles[1] = 'OFFICIAL', b;
ClassTitles[2] = 'PROPRIETARY' r;
ClassTitles[3] = 'RELEASABLE',g;
ClassTitles[4] = 'OFFICIAL', b;
ClassTitles[5] = 'OFFICIAL', b;
ClassTitles[6] = 'RELEASABLE',g;
ClassTitles[7] = 'RELEASABLE',g;
ClassTitles[8] = 'OFFICIAL', b;
don't use an enterframe listener. you can call initializeSlide when you change frames.
and use something like:
ClassTitles[1] = ['OFFICIAL', b];
banner_mc.txtBottom.defaultTextFormat=ClassTitles[currentFrame][1];
banner_mc.txtBottom.text=ClassTitles[currentFrame[0]
Copy link to clipboard
Copied
don't use an enterframe listener. you can call initializeSlide when you change frames.
and use something like:
ClassTitles[1] = ['OFFICIAL', b];
banner_mc.txtBottom.defaultTextFormat=ClassTitles[currentFrame][1];
banner_mc.txtBottom.text=ClassTitles[currentFrame[0]
Copy link to clipboard
Copied
Thank you very much it worked like a charm. Just for my knowledge "banner_mc.txtBottom.defaultTextFormat=ClassTitles[currentFrame][1];banner_mc.txtBottom.text=ClassTitles[currentFrame[0]" what do the [1] and [0] do?
Copy link to clipboard
Copied
ClassTitles is a 2-d array. the first index is the frame number and the 2nd is the textformat instance.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now