views:

106

answers:

1

I got an fla file with nested movieclips. The "username" text box is present in a movieclip "login" which is included in another movieclip "member".

How to access the value of the textbox "username" in actionscript when a button is clicked(on(release) event ). the button is also present in the "login" movieclip

A: 

I'm assuming you're using AS2 here...

If your button and your textbox are siblings (ie both contained in the same parent clip), then you can use this code on your button:

on (release) {
  trace(this);// should be 'login'
  trace(this.username.text);// should be the content of username textbox
}

This assumes that your button is tracked as a button and not a movieclip, otherwise you could use this._parent.username.text to get the contents of the textbox.

Another way is to use absolute addressing, but this is not recommended, since it's easy to break: either _level0.login.username.text or _root.login.username.text

Hope this helps!

Richard Inglis