Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Flash: Getting at a textfield instance within a button

    I feel quite stupid trying to alter the properties of a dynamic textfield in my flash movie at runtime, through ActionScript. I know the basic scripting to do that, however I can't find the right path to the textfield instance. The textfield ("content") lies in a button symbol ("inner"), which again is inside a movie clip symbol ("foobar"), which is placed on the current timeline ("_root"). Seeing from the "Insert Target Path" tool, the path to the button is

    _root.foobar.inner

    but from there I can't get at the the textfield object in the button. The path

    _root.foobar.inner.content

    returns nothing, though from my understanding it would be correct. There's nothing shown in the target path utility either.

    So how can I reference a button's textfield via ActionScript? I'm using Flash MX 2004 here, and am testing the scripts in the Flash 6 Player.

    Be kind to me if this post doesn't read to well, I'm more or less a n00b at ActionScript, and still confused about the way Flash exposes it's objects for scripting. Should the post lack any important information for this problem then tell me so and I provide what I can.
    De gustibus non est disputandum.

  • #2
    Senior Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    1,963
    Thanks
    0
    Thanked 0 Times in 0 Posts
    My Actionscript is pretty rusty atm as I've been doing more Director(shockwave)/Lingo stuff and it's all mixing together in my head..
    A couple of possibilities -
    1) The nesting of a dynamic textfield within a button *may* be causing your problem. Movies (and their children) can often do things that buttons cannot...
    2) *More likely:
    Code:
    _root.foobar.inner.content.text
    This is how Director accesses an elements text and I have vague memories of Flash being similar in that regard...

    This has probably been of very little help, sorry Ben

    I take no responsibility for the above nonsense.


    Left Justified

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I forgot completely about this thread. Thanks for your answer, things should have been as you described, but alas, buttons behave somewhat differntly. The people at the were-here forums set me on the right track.

    Basically all you need to do is to get rid of the button, and put the textfield into a movieclip, and attach onpress events to the movieclip to make it behave like a button. It simply does not work to access a button's child elements form outside. Thank you Macromedia for not documenting this, took me only half a day to find out, grrr.
    De gustibus non est disputandum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •