Scott Paterson
Scott Paterson

Reputation: 151

AS2 - Assigning variable text and text color

I have a flash file that contains text fields. I would like to assign the text fields via a flashvar as well as change the text color via a flashvar.

This changes the text color to red and works fine:

&textcolor=0xff0000

However this does not change the text color, but it does change the text contents correctly:

&textcolor=0xff0000&title=titlegoeshere

Here is my actionscript: - For some reason I have noticed that if I flip the order below and assign text first, color second, color doesn't work at all.

// text color
title.textColor = textcolor;

// assign flashvars
title.text = title;

How can I both assign color and contents? Could this be a bug in flash?

Upvotes: 0

Views: 432

Answers (2)

akmozo
akmozo

Reputation: 9839

Your problem is very easy, you have used the var title twice : as a textField and as a variable passed by flashvars. So to resolve this, you should change either your textField name or your var passed by flashvars like this :

HTML code :

...

<param name='flashvars' value='title_color=0xff0000&title_text=titlegoeshere' />

...

AS2 code:

title.textColor = _root.title_color

title.text = _root.title_text

Upvotes: 0

Scott Paterson
Scott Paterson

Reputation: 151

I just figured it out - for this situation you need to specify a different title and variable name. You can't use the same one.

Upvotes: 0

Related Questions