3

Essentially I'm wondering how I would have a text box pop up and every time you press e, the next string of text will appear. Then, once you get to the end of the array of text, the textbox art should disappear.

Is there anyone that could point me in the right direction?

0
  1. Build the pop up box, basically a MovieClip with a dynamic TextField. When you convert it to a Symbol, name if MyPopUp and associate a MyPopUp class with it. Give the TextField an instance name of textField.

  2. In the parent MovieClip, place an instance of MyPopUp where you want it to pop up. Give it an instance name of myPopUp.

  3. In the parent MovieClip initialization code, call removeChild(myPopUp) to hide the pop up box.

  4. When you want to show the pop up box, call addChild(myPopUp).

  5. To update the pop up box text myPopUp.text = "New Text";

    Note that the MyPopUp class provides a method for getting that text to the TextField.

  6. When you want to hide the pop up box again

    if (contains(myPopUp)) removeChild(myPopUp);

  7. Here's the class for MyPopUp:

    package  {
    
        import flash.display.MovieClip;
        import flash.text.TextField;
    
        public class MyPopUp extends MovieClip {
    
            public var textField:TextField;
    
            public function MyPopUp() {
                addEventListener(MouseEvent.MOUSE_OVER,onMouseOver);
                addEventListener(MouseEvent.MOUSE_OUT,onMouseOut);
            }
    
    // This method allows the parent to set the text by
    //  myPopUpInstance.text = "whatever"
    
            public function set text(newText:String) {
                textField.text = newText;
            }
        }
    }
    
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.