Dynamic text color

I am trying to use an xml document to dynamically load the
text color into my movie, and i can get the color, but when I try
to use that value to change the text color, it doesn't do anything,
how can I get this to work?
Thanks
This is my code:

There are two issues here I think.
1. Getting the correct value.
var txtColor:Number =
XPathAPI.selectSingleNode(this.firstChild, path+"/textColor/*");
This probably gives you a correct trace (if the xpath is
correct for what you want to do) but the trace is misleading.
trace applies the toString method to its arguments (I
believe). And putting the :Number there doesn't make it a number,
the compiler just treats it like one.
What you actually have is this:
var txtColor:XMLNode =
XPathAPI.selectSingleNode(this.firstChild, path+"/textColor/*");
and if
trace(txtColor.nodeType)
shows '3' then you have a textNode which contains the value
you're after.
So, try this:
var txtColor:Number =
Number((XPathAPI.selectSingleNode(this.firstChild,
path+"/textColor/*").nodeValue);
This *should* get you the value you need.
2. Assigning the value
If the above works, then assigning the number should be
fine...but just to clarify the other points....
Regardless of whether its flash 8 or flash CS3 the compiler
will give an error with the string assignment to a textfield's
textColor property if your textfield has been declared as a
TextField.
E.g.
This fails:
var testtext:TextField;
testtext.textColor ="0xff00ff";
But this works without the declaration:
testtext.textColor ="0xff00ff";
If you're getting that error then you need to use
Number(stringValue) and it will work.

Similar Messages

  • Changing dynamic text colors ??

    In Flash 8, the dynamic text field instance name is
    energyLevel, as is the variable name associated with it. This
    field's text color was originally set to gold (outside of
    ActionScript). In the code, I'm trying to change it to red (without
    a condition at this point, just to see if it will work).
    In the code prior to the init function:
    energyLevel = 10;
    I've tried Option 1: >>>>>>>>>>
    newTextStyle = new TextFormat();
    newTextStyle.color = "0xFF0000";
    actor.onEnterFrame = function() {
    energyLevel.setTextFormat(newTextStyle);
    I've tried Option 2:
    >>>>>>>>>>>>>
    actor.onEnterFrame = function() {
    energyLevel.textColor = 0xFF0000;
    And, I've tried Option 3:
    >>>>>>>>>>>>
    actor.onEnterFrame = function() {
    _root.energyLevel.textColor = 0xFF0000;
    BUT, none work. This should be easy to do. Can anyone tell me
    what is wrong??
    Thanks!

    not exactly, read:
    HERE
    What if you are tracking a value that you don't want to
    display at the time, or want use it in other calculations. Also
    there are a few other ways to enter what you've got there, as in:
    amountLeftField.text -= AmountFraction*.332;
    amountLeftField.text *=.332;
    amountLeftField.text /=1.332;
    OR how about ...
    a_txt.text -= f*.332;
    Flash recognizes operations on a numerical value entry,
    performs the calc, and still displays as a String.
    Additionally, if you use the underscore with an extention
    name for instance naming as in 'my_txt', Flash will recognize the
    extention and bring up a list of methods, properties and event
    handlers related to the data type when you type 'dot' after, if you
    have the 'code hints' preference turned on. Same with _mc, _btn,
    _ldr, _ti, _cb, ... etc. good for learning, and as you type the
    next few characters of the prop, the list will highlight the prop,
    and you can hit 'enter' to complete the rest, handy.
    I'm not certain, but I believe that the TextField Var
    property has been eliminated entirely in AS3. (?)

  • Dynamic text link hover color change.

    I have some dynamic text in Flash and I have a link with the text. Is there a way I can change the hover color without CSS? Here is my code.
    thanks.
    data=EASTERN CANADIAN DISTRICT<br><a href='mailto:[email protected]'><font color="#51884B">Mike Linnen</font></a><br>905-430-0955<br>Cell: 905-409-7159

    Disable the "Show border around text" option of your dynamic
    text field.
    Draw a rectangle with the color you want, & locate it
    behind your dynamic text field.

  • Dynamic Text and color changes......

    In some cheap website creating software I have you can turn
    text into rich text and change the color of individual words inside
    the same text box full of text. Is there anyway to do that in flash
    CS3?

    Thanks clbeech I actually found an easy way to do it. For
    your dynamic text box you can click the "html" box in the
    properties window for that text box. (Its a little square box with
    this <> inside it and its just to the right of the singleline
    and multiline box drop down.) You can then select the text you want
    to edit inside the text box and change its font/size/color as well
    as turn it into a dynamic link and it will do so without affecting
    the rest of the text in your text box.

  • Change Text Color Dynamically Depending on Which MP3 File is Playing

    Change Text Color Dynamically Depending on Which MP3 File is
    Playing
    Hi,
    Can anyone help with this problem.
    I am trying to change a text cast member's color dynamically
    based on which audio file is currently playing.
    I have 4 Text Cast member buttons named
    Play Song 1
    Play Song 2
    Play Song 3
    Play Song 4
    I am successfully playing the 4 songs in a queue like this
    (ie. If "Play Song 1" sprite text member is pressed then...
    sound(1).queue(member "Song1")
    sound(1).queue(member "Song2")
    sound(1).queue(member "Song3")
    sound(1).queue(member "Song4")
    sound(1).play
    What I would like to do is to have the currently playing song
    text color changed to a different value, say Green.
    So if "Song2" in the queue starts to play then the text "Play
    Song 2" would become Green. When done it would then turn back to
    black then "Song3" starts to play and "Play Song 3" text script
    button would then turn from black to Green an so on.
    These are the codes I've tried in the frame script and none
    seem to work...
    on enterFrame me
    if sound(1).status = 3 then member("Play Song 1").foreColor=5
    (This works but only for the first song because "Play Song 1"
    is directly named and clicked on.)
    else member("Play Song 1").foreColor=255
    end if
    I have tried to make a reference to the playing song and so
    far each of these doesn't work...
    --if sound(1).status = 3 then
    sprite(me.sound.member).foreColor=5
    --if sound(1).status = 3 then
    sprite(me.spriteNum).member.color=rgb(0,255,0)
    --if sound(1).status = 3 then member
    (sound(1).member).foreColor=5
    --text = member(whichMember).scriptText
    end
    Is there any way to reference the song name text cast
    member??
    I thought I had it when I discovered sound(1).member but
    sound(1).showProps returns the playing sound.member as
    member: (member 28 of castLib 1) nothing there I can use?
    It doesn't show the member name and
    It doesn't show the song name "Song1" which I could then
    match up to the "Play Song 1" text
    I'm pretty new to lingo so specific code examples would be
    appreciated.
    Can anyone help??? Thanks!!!

    did you get anywhere with this?
    When applying a styleClass to a af:showDetailItem, it doesnt seem to have any effect whatsoever.

  • Linking a class to a dynamic text field to load XML data.

    Hi,
    I'm quite new to ActionScript and would be grateful for any help here.
    I want to load text into a dynamic text field (called 'about_tab') using  a class depending on the language selected (by clicking on a flag icon)  by the user.
    I managed to get this to work when the ActionScript was written directly  in the timeline, but am having problems with doing the same thing via a  class.
    This is my class file:
    package
    import flash.display.SimpleButton;
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.net.URLRequest;
    import flash.net.URLLoader;
    import flash.events.Event;
    public class ChangeLang extends SimpleButton
    public function ChangeLang()
    addEventListener(MouseEvent.CLICK, switchLang);
    trace("ChangeLang class working");
    public function switchLang(event:MouseEvent):void
    var lang = event.target.name;
    var req:URLRequest = new  URLRequest("languages/"+lang+".xml");
    var loader:URLLoader = new URLLoader();
    var substance:XML;
    function xmlLoaded(event:Event):void
    trace("function xmlLoaded is running");
    substance = new XML(loader.data);
    about_tab.text =  substance.about_lbl;
    loader.addEventListener(Event.COMPLETE, xmlLoaded);
    loader.load(req);
    Here's one of my XML files (the other is the same except "About" is  written in German):
    <substance>
    <about_lbl>About</about_lbl>
    </substance>
    When I run it, it returns my trace statements that the class ChangeLang  and the function xmlLoaded are running, but no text appears in the  dynamic text field (I should/want to see the word 'About'). I get this  error message:
    1120: Access of undefined property about_tab
    The problem, I'm guessing, is in the part in red in my code. I think I need to target the text field in the display list by creating a  reference to it. If so, could someonw point out how I do this, or perhaps a tutorial that would help. I've tried adding the word stage (i.e.,stage.about_tab.text =  substance.about_lbl; ) but it still doesn't connect. I guess there's something really simple I'm missing, so I  apologize if this comes across as a stupid question
    Thanks for any help.

    Hello flashrocket!
    I'm also new to AS3 and I've just started using external classes and I think I know what you should do to put your code to work.
    Instead of using the text field you created inside your flash file, why don't you use the "TextField" class to create an instance of this object? It's the exact same thing as when you create and instantiate a new text field inside Flash.
    First, import flash.text.*; (includes classes like TextField, TextFieldAutoSize, TextFormat, TextFormatAlign, etc)
    Than you just have to create a var like
    public var about_tab : TextField;
    or
    public var about_tab : TextField = new TextField();
    then, to adjust the properties of this tab you use dotsyntax as if it where on your stage like:
    about_tab.x = 50; about_tab.alpha = .5; etc...
    you can even create a function to "config your textField"
              private function createAndConfigTextField() : void {
                   about_tab = new TextField(); //you only need this line if you
              // only typed something like "public var about_tab:TextField;
              // if instead you used "public var about_tab:TextField = new TextField(); outside
              // this function, just skip this first line because you already have an instance of
              // text field named "about_tab"...
                            about_tab.autoSize = TextFieldAutoSize.CENTER;
                   about_tab.background = true;
                   about_tab.border = true;
                   var aboutTextFormat : TextFormat = new TextFormat();
                   format.font = "Arial";
                   format.color = 0x000000;
                   format.size = 11;
                   format.bold = true;
                   format.align = TextFormatAlign.CENTER;
                   about_tab.defaultTextFormat = aboutTextFormat;
                   addChild(about_tab);
    This is just an example of what you can do... I hope you get it... let me know if you have any doubt...

  • Targeting Dynamic Text Box inside moviecip with variable

    Hi,
    How does one target a dynamic text box to change the border
    color inside of a movie clip? Example below which does not work
    theName = ("answerPrint" + arryCount);
    boxName = ("box" + (arryCount+1));
    _root.pagePrintPartA[theName][boxName].border = true;
    _root.pagePrintPartA[theName][boxName].borderColor =
    0x00cc66;

    Thanks for the reinforcement, but I should of indicated what
    was what:
    theName = ("answerPrint" + arryCount);// Name of Variable
    inside Dynamic Text Box Inside MovieClip
    boxName = ("box" + (arryCount+1));// Instance Name of Actual
    Dynamic Text Box Inside MovieClip
    _root.pagePrintPartA[theName][boxName].border = true;
    _root.pagePrintPartA[theName][boxName].borderColor =
    0xFF0000;
    By certifying this script you showed me wher I went wron (not
    seeing the forest from the trees). The last two lines should be:
    _root.pagePrintPartA[boxName].border = true;
    _root.pagePrintPartA[boxName].borderColor = 0xFF0000;
    I was targeting backwards. Thanks alot DazFaz.

  • Help with delivering dynamic text through an external file, through XML?

    I'm struggling to find the best way to deliver dynamic text
    from an external file, through XML, to a Flash file.
    I use small Flash pieces to deliver multiple sets of content
    through a single .swf file. An example is here:
    http://www.esi-intl.com/public/government/federal.asp
    In the .swf file at the bottom, I'm using a three-scene .fla
    file. I'm putting the actionScript in the Actions layer atop each
    frame. Example:
    stop ();
    loadVarsText = new LoadVars();
    loadVarsText.load("fedNews.txt");
    //assign a function which fires when the data is loaded:
    loadVarsText.onLoad = function(success) {
    if (success) {
    trace("done loading");
    //Now that we know the data is loaded,
    //set the text content of the Text Field
    //with the instance name "scroller" equal to the
    //contents of the variable
    scroller.html=true;
    scroller.htmlText = this.var1;
    } else {
    trace("not loaded");
    In that .txt file, I'm putting the information like this:
    var1=<font face="tahoma,verdana,sans-serif" size="11px"
    color="#000000"><b><a href='
    http://www.esi-intl.com/public/classroomtraining/dau.asp'>DAU
    Grants ESI Course CON353
    Equivalency</a></b><br>Advanced Business Solution
    in Contracting (CON 353) is an equivalency for DAU's CON 3535
    course, Advanced Business Solutions for Mission Support. <a
    href='
    http://www.esi-intl.com/public/classroomtraining/dau.asp'><U><font
    color="#996633">Continue</font></U></a></font>
    So much of this is pick-ups from what I've researched in
    Google. I'm looking for a way I can feel more confident in my code,
    and also have that code follow CSS.
    Lastly, I recognize the problems in XML with using single
    quotes / double quotes, and the & symbol. This is one of my
    largest time sucks, and I'd like to find a better way to do this.
    Thank you

    Hi,
    Did you ever find a resolution to this? I'm having a similar
    issue that I can't seem to get multiline dynamic text working in
    CS3.
    The font is embedded but it just displays the first line, and
    then a blank. I'm sure this worked fine in Flash MX.
    Cheers, Ant

  • Dynamic text in Flash: a href="mailto:... tag?

    I am using an Access DB to feed text dynamically to Flash.
    Although some simple html tags work in the text, I tried putting in
    <a href="mailto:[email protected]"> link tag in and it
    didn't work. Does flash not support mailto links in dynamic text?
    Is there a workaround to get a link into the dynamic text that will
    open an email?

    Nevermind! It works - the link didn't change color so I
    hadn't realized the link actually worked... I'm a dummy. Flash is
    smart.

  • How to change dynamic text on mouse click of an object

    Here is my Project File.
    I'm wanting to change dynamic text when an object is clicked.
    I created 3 dynamic text boxes under "Selected Colors" and gave them instance names of selected_roof_color, selected_trim_color and selected_wall_color.
    When the user clicks a color (ie Arctic White) and then clicks say the roof, I want the "Selected Color" to display "Arctic White" to the right of "Roof:". 
    The colorable areas on the building have been given instances of roof, walls and trim.
    I used this tutorial to change in the textbox underneath the colors when you mouse over a color.
    Thank you for your assistance.

    My first button color is Arctic White and it has an instance of arcticwhite.
    The actionscript for the Arctic White Button is:
    on (release) {
        _root.fillColor = 0xf3f5f4;
        _root.brush.gotoAndStop(1);
    The roof button has an instance of selected_roof_color and my dynamic text field where I want "Arctic White" to appear is given an instance of selected_roof_text.
    Using your suggestion, my main Actionscript now has the following
    roof.addEventListener(MouseEvent.CLICK,roof);
    function roof(e:MouseEvent):void{
    selected_roof_text.text="roof";
    Looks like I've still got something incorrect as the selected_roof_text isn't changing when I click a color onto the roof.
    Can you explain what the F in "roofF" is?  Is that a typo?

  • Dynamic Text and changing Text in AS3

    I have a Dynamic Text box in my Library.  I drag it to my main stage and give it a name..it is now a movieclip. The name is 'mcAdmin'.  I added an event listener for MOUSE_OVER.  I want the text to change color, but for now I'm just trying to change the text; however, it's not displaying the change in text I want.  I do a trace, and the change is in there on the output window, but it is not displayed as such.  How can I :
    1) use AS3 to change the font color of the text
    2) use AS3 to change the text and have it display?
    function onMouseOver_txtAdmin(e:MouseEvent):void
    Mouse.cursor="button";
    //Current mcAdmin text is 'Administration'
    //I want to change the color of Administartion on Mouse_Over
    //but to test if I can get to anything, I'm just trying to change the text.
    mcAdmin.text="Hello";
    trace(mcAdmin.text);
    mcPPMB.alpha=.5;
    mcASB.alpha=.5;
    mcISO.alpha=.5;
    mcEA.alpha=.5;
    mcAdmin.alpha=1;
    mcAdmin.scaleX=1.25;
    mcAdmin.scaleY=1.25;
    Thanks.

    1st
    give the textfield a name, if it hasn't already (sounds like you put it in a movieclip).
    to change the text set the text property of your text field
    like this
    myTextField_txt.text = "here is the text";
    or if it is inside a movieclip
    myClip_mc.myTextField_txt.text = "here is the text";
    To change the color you would need to put a TextFormat on it. To keep the same fontsize, font etc. you could first get the TextFormat from your existing Textfield, change the color of the TextFormat and set it on the TextField.
    // get the Textformat of the first character
                var TF:TextFormat = myTextField.getTextFormat(0,1)
    // set the font color
                TF.color = 0xff0000;
    // put it on the whole text
                myTextField.setTextFormat(TF)

  • Dynamic text shifts when style changes

    I have some dynamic text fields that are set up so that when
    you rollover them (actually a button behind them), their formatting
    changes. This is done with some basic actionscripting, setting up 2
    different text format variables and attaching one or the other to
    the text field when a button is rolled over. The only thing that
    changes is color. When the text first appears all is well. But when
    you rollover the text and the color changes, on certain browsers an
    extra space can get inserted at the beginning of a new line, sort
    of like the old bug where text wrapping messes up and moves a space
    down to the beginning of a line. This happens on IE 6 and 7 and
    Safari, not Firefox. The player is 9. THanks.

    Did not, I was happier with the browser's display than with
    the embedded font version. May try it just to see if problem
    remains. Seems like something I should be able to avoid without
    having to embed though.

  • Dynamic text variable

    I have a dynamic text box call "color.txt" at the root and
    two Movie clip buttons one called Red and one called Yellow.
    When I press the button the name of the button is passed to
    the text box. When I press the second button the
    name is not replaced. Do I have to create a seperate function
    to do this or is there another way?
    Thanks,
    _root.red.onPress = function(){
    _root.colorTxt.text = "Red";
    _root.yellow.onPress = function(){
    _root.colorTxt.text = "Yellow";
    }

    I got it working like this.
    var colors:Array = ["red", "yellow"];
    var currentColor:Number;
    function changeButton(newColor:Number) {
    currentColor = newColor;
    _root.colorTxt.text = updateText();
    _root.red.onPress = function(){
    changeButton(0);
    _root.yellow.onPress = function(){
    changeButton(1);
    function updateText():String {
    var newText:String;
    newText = colors[currentColor];
    return newText;
    }

  • Dynamic text property

    i have a dynamic text box with the name 'prodName'
    in the actions layer I have set prodName.text = "something";
    prodName.textColor = 0x000000
    When I test it, the color code works fine, but the dynamic
    text doesnt. I have tried htmlText on and off. Tried embedding and
    not embedding. Cant figure out why this wont work. I have done this
    before, what am I missing this time?
    chers
    mm66

    Well it turns out it was the embedding after all. Turning off
    ALL embeded fonts fixes it. So what happens with end users who do
    not have the fonts? I recall seeing some posts about that now
    cheers for the replys
    mm66

  • Dynamic Text in Externally Loaded swf

    hi. i have a dynamic text field in an externally loaded swf. Its a digital clock so i want the numbers to update in the dynamic text field.
    this is not my exact code but it is very similar. i show below that i add the loader.swf, and once its loading is complete, i can work on its movieclips and add event listeners to its buttons, etc. but i cannot change the dynamic text field (its "classic text" set to "dynamic text"). after running this, the text just stays empty as it is in the external swf).
    here is the sample code:
    var loader:Loader = new Loader();
    loader.load(new URLRequest("loader.swf"));
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
    function loaded(event:Event):void{
         addChild(loader);
         var loader_mc:MovieClip = (loader.content as MovieClip)
         loader_mc.myMovieClip.gotoAndStop(2);//***this works
         loader_mc.myButton_btn.addEventListener(MouseEvent.CLICK, clickMe);//***this works
         loader_mc.myText_txt.text = "12";//***this doesn't work******
    please help. thanks!

    Did you embed the font in the textfield--it needs to be done in the loaded swf when you create it? One other thing to check is that the color for the textfield is not the same as the background it sits on.

Maybe you are looking for

  • Can't open raw files in Adobe Bridge CS4

    First of all, I use a macbook pro that runs on Leopard.  My camera is 5d Mark ii.  I have photoshop elements 8 for mac, but I love to use Adobe Bridge CS4 for basic editing.  Here is my problem, it won't let me open raw mode to edit.  I have tried th

  • Email content with newline from R/3 using XI.

    Hi all, I am trying to send email from R/3 using XI mail adapter. For content I am using a String in R/3 but the interpreter does not recognize the new line char \n embedded in the string.When the mail arrives it comes as a single line. What is the r

  • Dijkstra's Algorithm in LabVIEW

    So I've attempted to undergo the painful task of trying to implement dijkstra's algorithm in LabVIEW. The problem is that I think I am going about doing this wrong, or at least not in the most efficient manner. I've attached my VI so people can take

  • Problem with CL_GUI_CFW= DISPATCH

    hi experts, when I double click on a node , the dispatch metod : CALL METHOD CL_GUI_CFW=>DISPATCH   IMPORTING RETURN_CODE = RETURN_CODE. returns ' -1'. ( RETURN_CODE = -1 ). means no event triggered, but I have double click on the node. Please tell m

  • Flash CC hangs every few seconds on Mac

    I work on two different Macs, one at home and one at work. On both of them, Flash will hang for a few seconds very frequently. I will be using the brush tool, the stroke doesn't appear, after a second or so there will be a spinning beach ball for ano