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

Need help, format text in an arrary

Explorer ,
Mar 21, 2016 Mar 21, 2016

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;

TOPICS
ActionScript
387
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

correct answers 1 Correct answer

Community Expert , Mar 21, 2016 Mar 21, 2016

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]

Translate
Community Expert ,
Mar 21, 2016 Mar 21, 2016

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]

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
Explorer ,
Mar 22, 2016 Mar 22, 2016

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?

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
Community Expert ,
Mar 22, 2016 Mar 22, 2016
LATEST

ClassTitles is a 2-d array.  the first index is the frame number and the 2nd is the textformat instance.

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