Be a Supporter!

Simple As3 Button Is Making Me Mad

  • 294 Views
  • 5 Replies
New Topic Respond to this Topic
kylelyk
kylelyk
  • Member since: May. 15, 2008
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Simple As3 Button Is Making Me Mad 2010-07-07 20:46:09 Reply

Here is the script in my document class:

package {
	import flash.display.*;
	import fl.controls:Button
	import flash.events.*;
	public class Main extends MovieClip {
		public function Main() {
			var startButton:Button=new Button()
			startButton.label="Play"
			startButton.x=width/2
			startButton.y=height/2
		}
	}
}

The debugger wanted me to change this:

import fl.controls.Button

To this:

import fl.controls:Button

What is going on?
Also, when I changed the line, is still gave an error for it saying I need a semicolon before the colon.????????


Kylelyk: Forwards and Backwards, Over and Out.

BBS Signature
Kirk-Cocaine
Kirk-Cocaine
  • Member since: Aug. 17, 2003
  • Offline.
Forum Stats
Moderator
Level 38
Programmer
Response to Simple As3 Button Is Making Me Mad 2010-07-07 21:19:23 Reply

The line should be this:

import fl.controls.Button;

The problem is however, that when creating components via AS you need an instance of that component in your library.


The water in Majorca don't taste like what it oughta.

| AS3: Main | AS2: Main | Flash Tutorials |

BBS Signature
kylelyk
kylelyk
  • Member since: May. 15, 2008
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Simple As3 Button Is Making Me Mad 2010-07-07 21:23:20 Reply

I have a button in my library, will that work?


Kylelyk: Forwards and Backwards, Over and Out.

BBS Signature
Kirk-Cocaine
Kirk-Cocaine
  • Member since: Aug. 17, 2003
  • Offline.
Forum Stats
Moderator
Level 38
Programmer
Response to Simple As3 Button Is Making Me Mad 2010-07-07 21:26:38 Reply

At 7/7/10 09:23 PM, kylelyk wrote: I have a button in my library, will that work?

It needs to be the button component (Window > Components, Ctrl+F7) and not just a button symbol.

If you want to create a button symbol use SimpleButton() instead of Button().


The water in Majorca don't taste like what it oughta.

| AS3: Main | AS2: Main | Flash Tutorials |

BBS Signature
kylelyk
kylelyk
  • Member since: May. 15, 2008
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Simple As3 Button Is Making Me Mad 2010-07-07 22:02:34 Reply

AHHHHHHH!!!! What's the difference between simplebutton and button component? How do each work?


Kylelyk: Forwards and Backwards, Over and Out.

BBS Signature
Kirk-Cocaine
Kirk-Cocaine
  • Member since: Aug. 17, 2003
  • Offline.
Forum Stats
Moderator
Level 38
Programmer
Response to Simple As3 Button Is Making Me Mad 2010-07-07 22:58:09 Reply

At 7/7/10 10:02 PM, kylelyk wrote: AHHHHHHH!!!! What's the difference between simplebutton and button component? How do each work?

A simple button is what you draw on the stage and convert into a symbol. A component button is pre-made and can be found in the components panel.


The water in Majorca don't taste like what it oughta.

| AS3: Main | AS2: Main | Flash Tutorials |

BBS Signature