OnClipEvent, Speed, Offset
Question 1
i guess the bottom line is why bother using clip events?
A: when i talked to Tage about it the answer was first of all notice that
the action was written on the button for the onClipEvent. So I then asked well why not just use onPress.....apparently onClipEvent is for non user initiated actions.
which renders onClipEvent useless b/c the currrent thinking is to not put actions on MC as much as possible. Thus its better to just use functions written on the timeline.
Question 2
speed and offset are they recognized flash words?
Offset is : (though it doesnt turn blue)
offset (Point.offset method)
public offset(dx:Number, dy:Number) : Void
Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to the original value of y to create the new y value.
Availability: ActionScript 1.0; Flash Player 8
Parameters
dx:Number - The amount by which to offset the horizontal coordinate, x.
dy:Number - The amount by which to offset the vertical coordinate, y.
Example
The following example offsets a point's position by specified x and y amounts.
import flash.geom.Point;
var myPoint:Point = new Point(1, 2);
trace(myPoint.toString()); // (x=1, y=2)
myPoint.offset(4, 8);
trace(myPoint.toString()); // (x=5, y=10)
Speed isnt recognized by flash its just a made up word. When I said to Tage
it doesnt seem logically that when i wanna move something that its connected to speed. I think of _x and ++ to move things but he said what if u wanted it to move faster tahn u have to think of speed.
But he said he also didnt get it why MR would do it this way;
this.ball_mc.speed = 6;
Tage says he does it this way var Speed:Number =6
-------------------------------------------------------------------------------------------
they both inititialize
onClipEvent (load) {
// init something here
this.speed = 4
}
this.ball_mc.speed = 6;
this.ball_mc.offset = (this.ball_mc._width * .5)
Both using on EnterFrame
Both using If statements
Both mc's
______________________________________________________________
file://localhost/Users/freelance/Desktop/ffffffflash/advFlash_20060622/ballBounce_01.fla
// hint!
/*
this.ball_mc.speedX = 6;
add sound:
var foo:Sound = new Sound();
*/
this.ball_mc.speed = 6;
this.ball_mc.offset = (this.ball_mc._width * .5)
this.ball_mc.onEnterFrame = function() {
this._x += this.speed
if (this._x > (300 - this.offset) ) {
// invert the speed
this.speed *= -1;
// position and play the clip
this._parent.animate_mc._x = this._x + this.offset;
this._parent.animate_mc._y = this._y;
this._parent.animate_mc.play()
} else if (this._x < (0 + this.offset)) {
// invert the speed
this.speed *= -1;
// position and play the clip
this._parent.animate_mc._x = this._x - this.offset;
this._parent.animate_mc._y = this._y;
this._parent.animate_mc.play()
}
}
____________________________________________________________
file://localhost/Users/freelance/Desktop/ffffffflash/advFlash_20060622/enterFrameLoops_01.fla
onClipEvent (load) {
// init something here
this.speed = 4
}
onClipEvent (enterFrame) {
// make it loop here
this._x += speed;
if (this._x > 300) {
speed *= -1;
} else if (this._x < 0) {
speed *= -1;
}
}