Search code examples
flashactionscriptdynamic-text

setting dynamic text value in Actionscript


I have a symbol called MapNameText and a dynamic text field inside called "innerText".

I'm trying to make it change the text when i click on the object they're all in but it doesnt work

Relevant part of my actionscript:

var MapName:String;

this.onMouseDown = function()
{

    trace(MapNameText['innerText'].text);

    MapName= MapNameText['innerText'].text;

    switch(MapName)
    {
        case "Classic":
        this.MapNameText['innerText'].text = "Crystal";
        trace(this.MapNameText['innerText'].text);

        case "Crystal":
        MapNameText['innerText'].text = "Volcano";

        case "Volcano":
        MapNameText['innerText'].text = "Classic";
    }
}

In the output window i get "Classic" "Crystal" But the text doesn't update in my object, it's confusing me a lot and im not sure what to do

Can anyone please lend me a hand with how to fix this?


Solution

  • Thanks for the reply! unfortunately that didn't resolve the issue, but after a little more tinkering a realized that i wasn't using 'Break'. It now works when i break off each case.

    for those with a similar problem, this is the resolved code

    switch(MapName)
    {
        case "Classic":
        this.MapNameText.innerText.text = "Crystal";
        trace(this.MapNameText['innerText'].text);
        break;
    
        case "Crystal":
        MapNameText.innerText.text = "Volcano";
        break;
    
        case "Volcano":
        MapNameText.innerText.text = "Classic";
        break;
    }