Dynamic text in AS2

Hi all,
Could someone please help me out with this. **I've attached an image of the swf file.
I'd like to be able to click on each of the buttons and have the background color change and also have its color name loaded in the dynamic text field.
E.g. Clicking the white square would change the background color to white and should also display the text ''white'' in the dynamic text box.
I've sorted out the colour changing part with the following code:
on (press) {
var colorful = new Color("_root.background");
colorful.setRGB(0xFFFFFF);
but I can't seem to get the dynamic text part working. Any ideas? I'd rather not load from an external file as the texts are short.
Thanks in advance for your help

give your textfield an instance name, say tf.  then if you're using simple buttons:
I've sorted out the colour changing part with the following code:
on (press) {
var colorful = new Color("_root.background");
colorful.setRGB(0xFFFFFF);
tf.text = "0xFFFFFF";
// if you're using movieclip buttons, use:
this._parent.tf.text = "0xFFFFFF";

Similar Messages

  • Setting dynamic text not working in AS2

    I'm working on a complex file given to me by another designer
    and I'm having a problem with being able to set dynamic text.
    Basically, I just want to set the text of a nested instance (e.g.,
    with an instance called foo and a instance inside foo called bar,
    I'm using foo.bar.text = "test".) This works beautifully and as
    expected in a test file. But when I move the symbols and code to
    the other designer's file, nothing happens. I.e., the dynamic text
    is blank.
    I feel confident that I'm not making any errors (I'm using
    tested code and symbols!), but I cannot think what else could be
    causing the error. Mine is the only ActionScript in the entire
    file.
    Are there bugs with dynamic text? Could this have to do with
    font substitution? I did change the fonts to Arial and "device
    fonts" without effect.
    Thanks!

    I appreciate your taking the time to help me and others on
    this board. (I actually have another -- probably related question
    -- that has never been answered, but that one is more confusing
    because it involved multiple language support and worked *until* I
    embedded the font.)
    My understanding of Flash is definitely a mixed bag. I have
    encountered so many problems (really quirks) with Flash that I kind
    of start with the assumption that I'm dealing with something
    quirky.
    In this case, since I don't know your style, I just couldn't
    see where you were going with your questions. In any case, thanks.
    I'm smarter re Flash as a result of your help.

  • Dynamic text wont show up in movie - as2

    basically i have dynamic text fields that i have been trying to parse to an xml file. when i test the movie it does not work, all the fields are blank. but the info DOES show up in the output tab, so i know that it is making the connection.... it just doesnt show up in the movie. weird.
    here is my actionscript:
    var xml:XML=new XML();
    xml.ignoreWhite=true;
    xml.onLoad=parseXML;
    xml.load("popup.xml");
    function parseXML(){
    trace(this);
        if (success)
            var diagramNode=this.firstChild;
            var infoNode=diagramNode.childNodes[0];
            var nameNode=infoNode.childNodes[1];
            var ssnumberNode=infoNode.childNodes[2];
            var descriptionNode=infoNode.childNodes[3];
            var stockNode=infoNode.childNodes[4];
            var priceNode=infoNode.childNodes[5];
            var typeNode=infoNode.childNodes[6];
            var qtyNode=infoNode.childNodes[7];
        else {
            content="oops, this stuff is confusing";
    and here is my xml:
    <?xml version="1.0" encoding="utf-8"?>
    <diagram>
        <config>
        </config>
        <info>   
            <name>
                Pedal Set With Toe Cage and Straps
            </name>
            <ssnumber>
                P01LEM14139
            </ssnumber>
            <description>
                Pedal set comes complete with both left and right pedals, toe cages and straps. Pedals have 9/16” shaft diameter where pedal threads into the crank arm.
            </description>
            <stock>
                Item is in stock
            </stock>
            <price>
                $15.95
            </price>
            <type>
                EA
            </type>
            <qty>
                1
            </qty>
        </items>   
    </diagram>
    thanks, -mitchell

    ok, i must have been doing it wrong. i ended up following a different tutorial and i rewrote it this way and it works great now!
    function processXMLData(success)
        if (success)
            var rootNode=this.firstChild;
            var nameNode=findNode(rootNode, "name");
            name=getValue(nameNode);
            var ssnumberNode=findNode(rootNode, "ssnumber");
            ssnumber=getValue(ssnumberNode);
            var descriptionNode=findNode(rootNode, "description");
            description=getValue(descriptionNode);
            var stockNode=findNode(rootNode, "stock");
            stock=getValue(stockNode);
            var priceNode=findNode(rootNode, "price");
            price=getValue(priceNode);
            var typeNode=findNode(rootNode, "type");
            type=getValue(typeNode);
            var qtyNode=findNode(rootNode, "qty");
            qty=getValue(qtyNode);
        else
            content="oops, this is hard";
    function getValue(node)
      if (node && node.firstChild)
          return node.firstChild.nodeValue;
      return "";
    function findNode(node, nodeName)
        if (node.nodeName==nodeName)
            return node;
        for (var i=0; node.childNodes && i<node.childNodes.length; i++)
            var foundNode=findNode(node.childNodes[i], nodeName);
            if (foundNode!=null)
                return foundNode;
        return null;
    var xmlData=new XML();
    xmlData.ignoreWhite=true;
    xmlData.onLoad=processXMLData;
    xmlData.load("popup.xml");
    stop();

  • How can i set the dynamic text box to show variable value?

    In AS2, I can make a dynamic text box set a var name, when i
    use button set/change the var value, this textbox can show the
    value also.
    but In AS3, dynamic text box can't add var name. than how can
    i do it now?

    Set an instance name for the dynamic textfield. Then, to
    populate the textfield with the value of a variable, use:
    textFieldInstanceName.text = variableName

  • Dynamic Text Editor

    I am making a dynamic text editor.
    Some of the fonts do not embed well? I have imported the
    fonts, put a linkage name, assigned data to the label.
    Some of the fonts change, but not on the server?
    I am using the setTextFormat?
    Does anyone have any ideas? It would be greatly appreciated,
    Emma

    Hello I am wondering if you can help me. I am sorry I have no
    answer for your problem.
    I am looking to also create a custom text editor in flash but
    I have no idea on how to do that. Would you happen to have a
    tutorial or can direct me to one on the web that I can learn how to
    create such a thing?
    I am looking for tutorials on this subject for both AS2 AND
    AS3 based text editor creation.
    Thank you.

  • How to display Dynamic text after adding flash file to html

    Please help - I have a dynamic text field in a movieclip
    inside a main movieclip - Within flash the dynamic text display
    properly but once I load the file to an html page the dynamic text
    no longer display - It loads undefined in text box. However when I
    remove the movieclip from main movieclip text display no
    problem.

    that's as2 code, not as3. please post in the correct forum
    next time.
    either about.txt is not in the same directory as the html
    file that loads or embeds your swf or there's a case issue with
    about.txt really being About.txt, for example.

  • Dynamic Text - partially working

    If anyone is willing to assist me with this, it would be
    greatly appreciated.
    I've created an interactive animation. On load, a number
    appears in the dynamic text box. When button one is pushed, the
    number needs to change; when button two is pushed, the number needs
    to 'clear' - be replaced by '-.-'.
    The '-.-' shows up; the second number does not. For
    reference, in the code below, the 4.5 is in temp_txt on load; when
    the minmax_btn is pressed, no numbers show up in min_txt or
    max_txt; when the reset_btn is pressed, the '-.-' shows up in
    min_txt and max_txt.
    What have I got wrong in here?

    It's me again...
    Here is a simplified version of my code which doesn't change
    the result but which is only using recognized properties in AS2 (I
    got rid of "viewableRows" which was questionable...)
    The only problem is:
    How to make the second (or the third, the fourth, etc) page
    start printing at line (row) 81 instead of 20?
    I think the script "believes" that it must print 80 lines
    whichever the text is.
    To do so, it prints the FIRST 80 lines on page one then it
    prints the LAST 80 lines of the text.
    Is it a schizo script? :-)
    Gerry
    In real world, printFld has fixed dimensions (525, 650) and
    is automatically populated by other functions (text is always the
    result of a search and the search functions automatically format
    the text and send it to this field)

  • Dynamic text rendering in Cp4

    I'm having an issue with an embedded AS2 SWF that spawns a MovieClip containing a dynamic text field populated with ActionScript. When I publish/preview the Captivate movie with externalized animations, the dynamic text renders fine. However, when I do NOT externalize animations, the dynamic text appears garbled.
    I'd go ahead and externalize animations in this project, but there are other embedded SWFs in the project that work correctly only when they are not externalized.
    Anyone have experience with this or a similar issue?

    I just had a similar problem and fixed it by embedding the font into the Flash SWF and also embedding uppercase and lower case characters.
    Not sure why this was needed since I never had to do that with Captivate 3, but that was the only thing that corrected the problem.
    /Michael
    Click here to visit the www.captivate4.com blog

  • Embedding fonts in dynamic text fields

    I am having trouble embedding a font in my Flash file. I have the font in my library. I have the text field selected to that font with the * next to it.
    In my actions I have:
    vid_title_txt.embedFonts = true;
    If I set it to false instead, it shows a different font. But if it is set to true, nothing shows. I am running out of ideas what to look at to solve this issue. What am I doing wrong here?
    Thank you very much for any help with this!

    I am in AS2.
    I followed these steps.
    Open the Library panel (Ctrl+L).
    Add a font to your library - click the options menu in the upper right corner of the panel and select New Font from the menu.
    In the Font Symbol Properties dialog box select the font, size and style that you want and give the font combination a name. Click OK to close the dialog box.
    Right-click the font symbol in the library and select Linkage from the contextual menu.
    In the Linkage Properties dialog box, click the Export for ActionScript button to enable both the Identifier and AS 2.0 Class text input fields. Leave the default Identifier value and click OK to close the dialog box.
    Select the text tool from the Tools panel and draw a dynamic text field on the Stage.
    Give the text field an instance name of "my_txt". In the Font menu select the symbol name you gave the embedded font earlier. You should see a little asterisk (*) beside the name.
    In the Property inspector set the font size and style to match those in the Font Symbol Properties dialog box earlier.
    Open the Actions Panel and add the following code to Frame 1 of your Flash document:
    my_txt.embedFonts = true;
    my_txt._rotation = 15;
    my_txt._alpha = 10;

  • External Embedded Fonts, Dynamic Text Fields, Latest?

    Hi all,
    I'm stuck in Flash8 land. Mostly because I use mProjector and
    MDM Zinc to extend flash projectors and neither support AS3
    correctly to date. That said..
    Is a Flash8 SWF capable of using fonts embedded in "other"
    SWFs? I realize this is an ongoing difficulty and a well known area
    of confusion and well, I'm confused. All the attempts I've made so
    far in linking have succeeded or failed in various ways, but never
    fully work.
    What I'd love to do is use dynamic text fields populated by
    data from a database (or XML file), with CSS styling, using fonts
    that are embedded in a 'master font SWF'. (and I'd like ice cream
    with that too!)
    I import fonts into, say, 'shared.fla'. I set them all up for
    exporting via linkage (to shared.swf). I open up my other FLAs
    (say, main.fla) and I drag the fonts from the shared.fla library
    into main.fla's library. In looking at the linkage, I see it
    properly set it to Import for Runtime Sharing (shared.swf). I can
    see the font available in the main.fla font list and can select it
    and use it just fine. I have to set the dynamic text field to embed
    fonts to actually see them (and also
    myTextField.setStyle("embedFonts",true)).
    Now all that works well and fine, but the kicker is when I
    want CSS to style my text. If I specify a embedded font linkage
    identifyer in CSS, the text disappears. i.e. I load 'style.css' and
    I have h1 { font-family: someEmbeddedFont; }, the <h1> text
    will now disappear.
    Any clues in how I can specify a font to use in CSS that's
    embedded so it'll work, WITHOUT This font needed to be embedded in
    the actual library (as in, not a linked asset)? Because it works
    fine if I embed the font into every single SWF. But when I try to
    use it as a shared asset, this doesn't work.
    Any ideas on how someone can achieve this?
    This is so I can changed my shared.swf and supply all new
    fonts with the same linkage identifiers and change the font in a
    whole project without re-exporting any other SWFs.
    Thanks for any info!

    I guess it's amazing but I honestly, wholly cannot get this
    to work.
    I made a new AS2 Flash 8 FLA (Forte.fla) with only the Forte
    font with a size of 22 in the library. The name of the library
    element was Forte. The linkage was set to "Export for Actionscript"
    and "Export in first frame".
    I made another FLA (main.fla) Flash8 AS2. In actionscript I
    created an empty movie clip named "Asset_Forte" at the next highest
    depth and Asset_Forte.loadMovie("Forte.swf"). I also made a dynamic
    text field on the stage of this main.fla document and set it to
    Arial 22pt (no bold or italics, etc). I did not embed anything into
    it.
    I made a TextTormat object (my_fmt) and set my_fmt.font =
    "Forte";. I put some text in the dynamic text field to start so I
    just applied the formatting (status_text.setTextFormat(my_fmt);).
    This did not work. I started adjusting random things like
    naming the font in the Forte.swf library to Forte22 and tried
    my_fmt.font = "Forte22";. That didn't work.
    I adjusted the linkage to "Export for runtime sharing" and
    specified Forte.swf as the SWF to share from. This did not work.
    I then dragged the font from the Forte.fla's library (while
    "Export for runtime sharing" was enabled) into the library of
    main.fla. I checked the link and it was proper, "Import for runtime
    sharing, Forte.swf". I used both linkage attempts again (Forte and
    Forte22) with my_fmt.font and neither worked.
    Would it be possible at all to get a couple FLAs from you
    that examplifies how you do this particular trick? I can't seem to
    get the settings right. I would be indebted to you!

  • What's the code for applying CSS to an XML file, in a dynamic text feild

    Hi all,
    Very simply put, just like in the title.
    If you have a CSS ready, an XML file that already appears
    inside a dynamic text field, what AS2 code would you use to connect
    the CSS so it applies to the XML file which is now unstyled?
    thanks!!!

    ...sorry for thaking a while to get back to you. I pluged the
    code you provided and the exported flash does not deplay the text.
    instead it says "undefined" which to me means something in the xml
    files is work, which is strage since I tested the xml file in a
    browser and it works find. so i am providing both the AS code
    (below) and the xml and css file (attached). my hope is that you
    can direct me to what the problem is.
    THANK YOU AGAING FOR ALL YOU HELP!!!
    AS code:
    Scrolling Text XML by Digital Science |
    www.digitalscience.za.org
    /////////////Load XML Data/////////////
    function loadXML(loaded) {
    if (loaded) {
    xmlNode = this.firstChild;
    header = [];
    txt = [];
    total = xmlNode.childNodes.length;
    for (i=0; i<total; i++) {
    header
    = xmlNode.childNodes.childNodes[0].firstChild.nodeValue;
    txt
    = xmlNode.childNodes.childNodes[1].firstChild.nodeValue;
    gotoAndStop(11);
    } else {
    errorMsg.text = "Error loading XML";
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load("member_content_test.xml");
    stop();
    import TextField.StyleSheet;
    var ss:StyleSheet = new StyleSheet();
    ss.onLoad = function() {
    txt_mc.styleSheet=this; // where yourTF is your textfield
    ss.load("jokes.css"); // where yourSS.css is your css file.

  • Dynamic text links

    Can anyone help with this? I'm trying to get text on a screen
    to link to documents (that will be on a CD, currently on my hard
    drive) such as pdf, txt etc. Using Flash 9.
    Thanks.

    Thanks again for your reply. Since my last posting, I have
    gotten mostly everything figured out except the main issue, which
    is creating a link to documents from text. In the following code I
    was able to load dynamic text from an external txt file and I
    inserted an html link in the txt file but I don't want to open a
    browser link, but rather a file on CD or hard drive:
    var textLoader:URLLoader = new URLLoader();
    var textReq:URLRequest = new URLRequest("test.txt");
    function textLoaded(event:Event):void
    getStart_txt.htmlText = textLoader.data;
    textLoader.load(textReq);
    textLoader.addEventListener(Event.COMPLETE, textLoaded);
    So everything looks good, except how do I get the html link
    in the text file to open a doc instead of a url? Or maybe something
    in your post will work.
    Regarding buttons and code, this is from a Flash website:
    "So you just started AS3.0 full of excitement and ready for
    some coding challenges, you start coding your first button and
    suddenly, horror, you end up with "WARNING: Actions on button or
    MovieClip instances are not supported in ActionScript 3.0. All
    scripts on object instances will be ignored." or "1119: Access of
    possibly undefined property onPress through a reference with static
    type flash.display:SimpleButton.", indeed the good old AS2.0 event
    system is not working anymore in AS3.0: onClipEvent, onPress,
    onRelease, onLoad, onMouseDown ..etc, have become things of the
    past!!!
    What happened? well basically the whole event handling system
    has been revamped in Actionscript 3.0 and we are going to have a
    quick look at it."
    When I select a button in Flash 9, the error message I get is
    "Current selection cannot have actions applied to it."
    Thanks.

  • Dynamic Text Area with no scrollbars question

    Hello All,
    I have an application that has a dynamic text area that pulls in XML content and i would like to have the text area grow, rather than use a scrollbar and i am wondering if anyone has done this or can point me in the right direction? I have dont quite a few searches and only find examples on how to do this in AS3, and i am using AS2 and CS3.
    Thanks in advance!

    If you are using AS2, then if you manually stretch the width of the textfield to what you want it to be, you can use the following to have it automatically rezise itself height-wise to fit whatever text you assign to it, where tfield is whatever instance name you assign to the textfield in the example code...
    tfield.autoSize = "left";
    tfield.text = "whatever your xml file text is";

  • Displaying the result of a calculation in a dynamic text box

    Hi folks,
    I'm having a very minor issue here (operator error, I'm sure ). With the help of some folks here, I've created a series of calculations, and I've got that part down. Now, I just need it to show up in the movie.
    I've created the dynamic text box in Flash (CS3), but when I hit test, it won't show up.
    After all the calculations, I should have a figure that I call totalmoney. My dynamic text box is called total. The user doesn't need to hit anything for it to appear. It just appears as part of the movie.
    Here's my code:
    stop();
    var startDate:Date = new Date(2010,0,12);  // use your  startyear, startmonth, startdate in the new Date() parameters.
    var  currentDate:Date = new Date();  // assuming user's clock is correct and in your  timezone.  else use server date/time.
    var numberOfSeconds:Number =  (currentDate.getTime()-startDate.getTime())/1000;
    var interest:Number =  (numberOfSeconds*0.74356);
    var totalmoney:Number =  (interest+15,000,000);
    function displaytotal(evt:TextEvent):void {
         total.text = "totalmoney";
    Any thoughts?
    Thanks!
    Napo

    You didn't have to bury any of the calculations in the function--leaving it as you had it is better.  They could remain where they a=werew, and you'll probably find you want them outside it if you have other plans for using them.  If left inside, they only have scope inside.  In the programming world, it's good to think of functions as things that do one thing and one thing only (though it isn't often practiced that way)--it's called modular design.
    When you place an event as an argument for a function, it typically means that there is an event listener that initiates the call to the function.  If you work with buttons you'll see what I mean.  But if the plan is to create your own call to a function when you desire it as such, not have it driven by an event listener, then you don't need to pass any event to it, though you may pass some other type of variable to it if need be.
    For instance, what you have now will call the function without an argument because the function has the value built into its code....
    displaytotal();
    But you could also make the function a little more generic and set it up to recieve the value instead as an argument...
    function displaytotal(amt:Number):void {
         total.text = String(amt); // an earlier error of mine
    displaytotal(totalmoney);
    That would make your function a little more useful.  Now it could be used to display other Number variables as well.
    // my earlier error was that a textfield displays text, so you need to convert the Number value to s String.
    Hope I'm not confusing you.

  • Dynamic Text Field is not displaying foreign characters... HELP!

    I have a dynamic text field that is not displaying foreign characters properly. They appear as boxes.
    Here's what I've tried.
    Under properties for the text field, I clicked on the embed characters button. In there, I pasted all the special characters I would need and clicked okay. Shouldn't this be enough for the text to display properly? What am I missing? Please help...

    More info: I'm noticing that in the actual dynamic text field in my .FLA file, if I type a foreign character like é, it pops up as a block. My family font is set to New Caledonia... is it possible that New Caledonia doesn't have those particular glyphs? The thing that doesn't make sense to me though is, last year when I made this card, it worked fine with New Caledonia... Any help is greatly appreciated!!

Maybe you are looking for

  • Intermittent GPIB error 6 (EABO)

    my system: Mac OS 8.6, Labview 5.1, NI-488.2 for Mac OS version 7.6.3, PCI-GPIB card, Keithley 2182 Nanovoltmeter and Keithley 24xx Sourcemeters. I have a Labview application (modeled on Keithley's application note "Automatic Resistance Measurements

  • Using conditions on CSV files in Receiver Determination

    Hi, We're reading EDI files from a directory and turning them into IDocs. We've got an ABAP class that converts the EDI to XML for us, we're calling that as the first step in the Operation Mapping. However, several different EDI files are dropped in

  • How to insert the file name to column

    When user upload the file, in order to avoid the double file name conflict, so I need to  change the file name to something else, but I still need save the former file name to some column to download the file with correct file name, I know how to ren

  • I need help is takeing a solaris 9 soc drive to work in solaris 10

    I need to get a Sparc Storage Array to run under solaris 10. The soc driver that is needed is not supportted under solairs 10. I took the packages needed off of solaris 9 cds and installed them but no luck. I tried to to do a modload and modinfo but

  • Dequeue memory leak ?

    Hi I have the following code to dequeue a message: public static AqMsg2 deQueueMsg(Connection p_cn, String p_queueowner, String p_queuename) throws SQLException { //Disable autocommit p_cn.setAutoCommit(false); //Get a reference to the queue AqMsg2 v