Advertisement

05.22.2006 at 08:49AM PDT, ID: 21859314
[x]
Attachment Details

Change Dynamic Text Color Using Actionscript

Asked by kenfx in Macromedia Flash

Tags: text, color, actionscript, change, dynamic

I am using Flash 8 and I am building a flash stock ticker. I want to change the color of the text based on change of the stock (positive or negative). I have created a text file using aspx and I am loading the variables from that file (here's the sample output):

sym_0=ABP&trade_0=4.24&sign_0=0&change_0=-0.16&percent_0=-3.64&name_0=ABRAXAS PETRO (N&sym_1=AGII&trade_1=31.81&sign_1=0&change_1=-0.12&percent_1=-0.38&name_1=ARGONAUT GROUP IN&sym_2=ALG&trade_2=21.27&sign_2=0&change_2=-0.06&percent_2=-0.28&name_2=ALAMO GP INC&sym_3=CFR&trade_3=56.00&sign_3=0&change_3=-0.10&percent_3=-0.18&name_3=CULLEN FROST BNKR

I created a variable (sign_*) that denotes the change (0 = negative change, 1 = positive change).

Here's the code I have on my actions line of the movie, frame 1:

myData = new LoadVars();
myData.onLoad = function(){
   quote__0 = this.sym_0 + ": $" + this.trade_0 + ", " + this.change_0 + ", " + this.percent_0 + "% ";
   quote__1 = this.sym_1 + ": $" + this.trade_1 + ", " + this.change_1 + ", " + this.percent_1 + "% ";
   quote__2 = this.sym_2 + ": $" + this.trade_2 + ", " + this.change_2 + ", " + this.percent_2 + "% ";
   quote__3 = this.sym_3 + ": $" + this.trade_3 + ", " + this.change_3 + ", " + this.percent_3 + "% ";
   
               format = new TextFormat();
            format.color = 0x00FF00;
            
         if (this.sign_0 == 1) {
            tQuote_0.setTextFormat(format);
            };
       if (this.sign_1 == 1) {
            tQuote_1.setTextFormat(format);
            };
            if (this.sign_2 == 1) {
            tQuote_2.setTextFormat(format);
            };
            if (Number(this.sign_3) == 1) {
            tQuote_3.setTextFormat(format);
            };

};

myData.load("../stocks.txt");


All of the dynamic text boxes individual graphics, instances are given for each text box).
Everything works except changing the color of the font.

HELP!Start Free Trial
[+][-]05.22.2006 at 09:53AM PDT, ID: 16735867

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2006 at 10:19AM PDT, ID: 16736063

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2006 at 11:43AM PDT, ID: 16736782

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2006 at 11:44AM PDT, ID: 16736788

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.23.2006 at 06:24AM PDT, ID: 16742136

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.23.2006 at 06:35AM PDT, ID: 16742229

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.23.2006 at 06:46AM PDT, ID: 16742351

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Macromedia Flash
Tags: text, color, actionscript, change, dynamic
Sign Up Now!
Solution Provided By: Ramy_atef
Participating Experts: 3
Solution Grade: A
 
 
[+][-]05.23.2006 at 06:49AM PDT, ID: 16742378

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.24.2006 at 12:08AM PDT, ID: 16749003

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.24.2006 at 02:55PM PDT, ID: 16756220

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32