...

Flash: Getting at a textfield instance within a button

mordred
06-02-2004, 03:26 PM
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. :)

mindlessLemming
06-04-2004, 01:58 AM
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:

_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 :D

mordred
06-10-2004, 10:47 AM
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 (http://www.were-here.com/forum/tm.asp?m=1352781&p=4&tmode=1&smode=1).

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. :mad:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum