Be a Supporter!

Button help with AS3

  • 189 Views
  • 6 Replies
New Topic Respond to this Topic
Hero101
Hero101
  • Member since: Dec. 13, 2005
  • Online!
Forum Stats
Supporter
Level 20
Game Developer
Button help with AS3 Feb. 1st, 2013 @ 08:19 PM Reply

Hey guys. I haven't touched Flash in about a year and recently have been getting back into it. Decided to try and learn AS3 this time around and I am having trouble.

I've used code to stop at a certain frame in the timeline. On this frame there is a button (I do know the basics of setting up a button). What I want is that when it is clicked to have text appear on the screen and when the user finishes reading it to click an "ok" button to make the text disappear.

I figure I need an add.eventListener for the mouse click but to listen for what? Do I make the readable text a MC? Would this MC already be in place but is transparent until add.eventListener is activated?

Trying to have all of this happen on the same frame because the only way I know around this is to have to add.eventListener jump to another identical looking frame except with the text present but I don't want to do it that way.

Any help would be greatly appreciated.

Thanks in advance.


BBS Signature
MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to Button help with AS3 Feb. 1st, 2013 @ 08:44 PM Reply

Well first things first, if you're going to relearn AS3, relearn it correctly using a class based setup, not just code on keyframes.


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature
Hero101
Hero101
  • Member since: Dec. 13, 2005
  • Online!
Forum Stats
Supporter
Level 20
Game Developer
Response to Button help with AS3 Feb. 1st, 2013 @ 08:48 PM Reply

At 2/1/13 08:44 PM, MintPaw wrote: Well first things first, if you're going to relearn AS3, relearn it correctly using a class based setup, not just code on keyframes.

I've noticed this in other threads when I was searching for an answer to my question... Anyone care to explain what a
"class based setup" is...?

Also...I'm still looking for an answer to my question....


BBS Signature
Spysociety
Spysociety
  • Member since: Dec. 30, 2009
  • Offline.
Forum Stats
Member
Level 21
Blank Slate
Response to Button help with AS3 Feb. 1st, 2013 @ 09:02 PM Reply

At 2/1/13 08:48 PM, Hero101 wrote:
At 2/1/13 08:44 PM, MintPaw wrote: Well first things first, if you're going to relearn AS3, relearn it correctly using a class based setup, not just code on keyframes.
I've noticed this in other threads when I was searching for an answer to my question... Anyone care to explain what a
"class based setup" is...?

What Mint meant is that instead of writing code in AS1 style on the main timeline, use what AS3 brings powerfully to you, the object-oriented programming, create a class for you button, learn how to deal with document classes etc.

Diki made a tutorial for AS3: Main about that.

MSGhero
MSGhero
  • Member since: Dec. 15, 2010
  • Offline.
Forum Stats
Supporter
Level 16
Game Developer
Response to Button help with AS3 Feb. 1st, 2013 @ 09:04 PM Reply

At 2/1/13 08:48 PM, Hero101 wrote:
At 2/1/13 08:44 PM, MintPaw wrote: Well first things first, if you're going to relearn AS3, relearn it correctly using a class based setup, not just code on keyframes.
I've noticed this in other threads when I was searching for an answer to my question... Anyone care to explain what a
"class based setup" is...?

Also...I'm still looking for an answer to my question....

Check out FlashDevelop. It's free and it makes you code with classes. A class is basically the blueprint for a thing, telling it what its properties and methods are; MovieClip is a class, it has x, y, rotation, etc properties. Egg's guide is helpful for getting started.

To answer your question, use a mouseclick event listener to add and removechild a textfield.

Hero101
Hero101
  • Member since: Dec. 13, 2005
  • Online!
Forum Stats
Supporter
Level 20
Game Developer
Response to Button help with AS3 Feb. 1st, 2013 @ 09:13 PM Reply

Thank you guys for your input! I'm very grateful for the advice and the links to the tutorials!


BBS Signature
milchreis
milchreis
  • Member since: Jan. 11, 2008
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to Button help with AS3 Feb. 2nd, 2013 @ 06:04 AM Reply

To transition from frame script to classes, look at this:
http://www.untoldentertainment.com/blog/2009/08/25/tutorial-
understanding-classes-in-as3-part-1/

make sure to read the other parts as well