Search code examples
flashactionscript-3flash-cs3

How to set attribute of instance with specified name defined on multiple frames


I have a tab button in a movieclip with 3 different states keyframed - popup, hover and up. I use the textfield on each state to show tab title - the problem is I cannot use the same position for the textfield on each keyframe, so I keyframed the textfield's position. And in both keyframes for the textfield it has an instance name tabText. And when I assign text to it - it changes on one keyframe only. How should I resolve this situation without adding the textfield programmatically?


Solution

  • the only way to do this would be to add a variable that is containing the text and update the textfield with that every time you change keyframe. ideally you would avoid all of this and either use a static text for each frame or alternatively adjust the position programatically.

    //initialising the variable, in frame one etc.
    var content:String = "text in here";
    
    // In every Keyframe
    tabText.text = content;