Okay, lets get to my problem. If I pass variable(s) like this in document class action script file(I’m not even sure if I can pass more than one variable):
ballPointRight = new BallPointRight(ball, xDir, padScreen) ;
And now the BallPointRight’s action script file:
package {
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class BallPointRight extends MovieClip {
public var ball:Ball;
public var xDir:Number;
public var padScreen:PadScreen;
public var timerRightPoint:Timer;
public function BallPointRight(ball:Ball, xDir:Number, padScreen:PadScreen) {
timerRightPoint = new Timer(10);
timerRightPoint.addEventListener(TimerEvent.TIMER,mainRightPoint);
timerRightPoint.start();
}
public function mainRightPoint(timerEvent:TimerEvent):void {
this.x = ball.x;
this.visible = false;
if (PixelPerfectCollisionDetection.isColliding(this,padScreen,this.parent,true) || this.x >= 550) {
xDir = -1;
}
}
}
}
Okay so here it seems that if I specify variables in constructor function
(ball:Ball, xDir:Number, padScreen:PadScreen)
then I can just use them inside constructor function. But I can’t use them inside other functon (mainRightPoint)? So how could I make it work. Now the
this.x = ball.x;
this.visible = false;
if (PixelPerfectCollisionDetection.isColliding(this,padScreen,this.parent,true) || this.x >= 550) {
xDir = -1;
}
doesnt work since it doesnt recognize variables…