Category Archives: pixels

A little homework..

I’m updating actionscript unit from as 2 to 3.  Not an easy process….

import flash.events.Event;

/*function calculate(event:MouseEvent):void
{
total_txt.text = value1_txt.text + value2_txt.text
}
calculate_btn.addEventListener(MouseEvent.CLICK, calculate);
*/

//the above sample concatenates v1 and v2 how do we convert the data type?

function calculate(event:MouseEvent):void
{
total_txt.text = String(Number(value1_txt.text) + Number(value2_txt.text));
circle_mc.x -= 10;
}
calculate_btn.addEventListener(MouseEvent.CLICK, calculate);

//the Number() tool is a temporary translates the value, then you have to convert both back
//to a string to it can match the total_txt.text string.  Plew!!!!

function moveRight(event:Event):void
{
circle_mc.x += 1;
}

circle_mc.addEventListener(Event.ENTER_FRAME, moveRight);

//above will move the circle_mc instance x + 1 on the enter frame (means this will loop)




/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.

Instructions:
1. Add your custom code on a new line after the line that says “// Start your custom code” below.
The code will execute when the symbol instance is clicked.
*/

button_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{
// Start your custom code
// This example code displays the words “Mouse clicked” in the Output panel.
trace(“Mouse clicked”);
// End your custom code
}

//above is code snippet example of click handler, students need a strong understanding of functions before they get this.


http://www.actionscript.org/forums/showthread.php3?t=236069   – link to whack a mole