CTRL+F7 to toggle the components window on and off (you want it visible). Or use Window - Components
Drag a button onto your canvas.
Give it an InstanceName of myButton.
Change the button's label from Label to Hello.
Drag a Label onto your canvas.
Give it an InstanceName of myLabel.
Change the label's text from Label to Snoozing or use any other text you like.
The numbered steps above are labelled onto the screen shot below to indicate where your tasks are located.
Your window will look something like this ...
Click on your canvas (but not on the button or label) and press F9 to toggle on the Actions - Frame window. If you see this message, read this instruction again and do it right! "Current selection cannot have actions applied to it."
function sayHello(e:MouseEvent):void
{
myLabel.text = "Hello World!";
}
Save your work to a well named folder and give your file a meaningful file name.
Press CTRL+ENTER to run your Flash Application. If it doesn't work correctly, look for mistakes in your code (copy and paste it to reduce the chances or error). Look for mis-spellings of myButton and myLabel, both in the code and in the Properties Window.
Here is the code with explanatory comments.
// This line makes the button listen or wait for mouse clicks.
// When the button feels a mouse click, it calls the sayHello function. myButton.addEventListener(MouseEvent.CLICK, sayHello);
// This is the sayHello function.
// When this function is called, it sets the text property of myLabel to "Hello World!".
// e:MouseEvent is the click experienced by the button.
// void is used here because this function, although useful, does not return a value. function sayHello(e:MouseEvent):void
{
myLabel.text = "Hello World!";
}
Optional tasks: Make your canvas smaller and change the background colour.