Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Button onLoad? Constructor?

Explorer ,
Jun 16, 2006 Jun 16, 2006
I haven't worked with Actionscript in a LONG time... back before it was much of anything. So if I'm going about this wrong, I apologize.

I want to name a button instance on the stage at dev time and have the text set to the name of the instance at run time. I figured I could find the name of the instance(it's gotta be a property somewhere in there, right?) and just assign that string to the of the dynamic text field I placed in the button.

This just seems like a nice, clean, easy-to-maintain way of using a button.. when clicked, it would pass it's name to some handler at the root which would figure out what to do with it.

Ideas? Counter-ideas?

Thanks in advance,


Scott.
TOPICS
ActionScript
308
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 16, 2006 Jun 16, 2006
mc._name
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 16, 2006 Jun 16, 2006
LATEST
Didn't realize I had to embed it in a movieclip. Now it all seems to make sense, except it's not working...!

OK. So, here's what I've got so far:

I have a button called btn_blue in my library with the four states, up/over/down/hit.

Within btn_blue, I have two layers: textLayer and bgLayer.

Within textLayer, I have a textField called optionText (set to dynamic text, obviously.)

In my movieClip, I have an instance of btn_blue called thisButton.

The code at the top of the movieClip (Layer 1, Frame 1), I have:

onLoad = function() {
thisButton.optionText.text = this._name;
}

But no workie. I must have my references wrong somehow, but I'm feeling a bit lost.

Halp?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 16, 2006 Jun 16, 2006
mc._name
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines