0

I am trying to create a button using Actionscript. The only class which I found relevant was SimpleButton. When I had tried to insert a text field earlier, I found it was very simple and straighforward in that, I just created a text field, and added text to it. It got rendered fine.

However, when I tried to do something similar, I found that it wasn't getting rendered. I referred to the help document on the Adobe Site and pasted their sample code as a standalone file. It worked fine. However, the button was just coloured. I wanted to add some text on it - so I used the text field and overlaid it. Which looks fine. But now when I bring the mouse close to the text, the button's hover no longer works, nor does the click - This I believe is because of the text being over the button.

To summarise, how do I create a clickable button with text using Actionscript without problems?

2 Answers 2

2

On your Textfield you can set a property:

myTextfield.mouseEnabled = false;

That way your textfield won't be preventing you from clicking.

Sign up to request clarification or add additional context in comments.

Comments

1

If you want to use graphic interface to create button(s) do the following:

  1. Open Components window and expand User interface section.
  2. You will find a Button component there
  3. Drag it to your stage
  4. Change the label, you can also change the 'skin'
  5. Enjoy

SimpleButton is an Actionscript class meant to facilitate programmatic creation of the buttons. If you find it more suitable for your needs just remember to set the overlaying text field to ignore the mouse events:

textField.mouseEnabled = false;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.