Thursday, February 3, 2011

Class Notes Stuffs


//the first is the delay in  miliseconds. The second is the repeat count
//you have to add an event listener for the timer event.timer

var timer:Timer = new Timer (10,0); //1000 for real clock, 10 to  speed it up so we can see what is happening

timer.addEventListener (TimerEvent.TIMER, onTimer);

function onTimer(event:TimerEvent):void {
// trace(“timer”);
rectangle01.rotation +=6;  //360/60
rectangle02.rotation +=.1;  //360/60/60
rectangle03.rotation +=.00833333;  //

//triggered when the timeline goes into a certain frame (in the playhead)
//unless you put in a stop frame it keep going at the specified frame rate

//rotating on the enter frame event

// variables
var speed:Number = 10;

// event listenters
stage.addEventListener(Event.ENTER_FRAME, onFrameLoop);
stop_mc.addEventListener(MouseEvent.CLICK, onStop);
go_mc.addEventListener(MouseEvent.CLICK, onGo);

// event handlers
function onFrameLoop(george:Event):void {
    rectangle01_mc.rotation += speed;
} //essentially speed is 10 because that is what set the variable equal to

function onStop(event:MouseEvent):void {
    //speed = 0;
    stage.removeEventListener(Event.ENTER_FRAME, onFrameLoop);
//you have to have both the event and the even handler (just copypaste and change add to remove)

function onGo(event:MouseEvent):void {
    //speed = 10;
    stage.addEventListener(Event.ENTER_FRAME, onFrameLoop);

//if you give negative number it rotates counter clockwise


dynamic_txt.text = "Ross Higgins";

button_mc.addEventListener(MouseEvent.CLICK, onClick);

function onClick(event:MouseEvent):void {
    //var theInput:String = input_txt.text;
    dynamic_txt.text = input_txt.text;

//there are 2 different types of text engines now in Flash
//the TLF (CS5) more complex and allows you to link multiple boxes so that text can overflow into the next box
//The classic text box: The Static Text, The Dynamic text box (can give it an istance name so we can update it), Input Text (we can also give it an instance name in order to withdraw the information and use it in our code)
 //the fonts should automatically embedd, in the TLF text fields you have to embed them.

No comments:

Post a Comment