Hi. I have this movement, but for now it’s just working on click and I can’t seem to figure it out how to make it fluid and nice without clicking on it.
Here’s some parts of the code that I have so far. Thanks for the help.
selectStar = function(){
cameraView.target.x = this.x;
cameraView.target.y = this.y;
cameraView.target.z = this.z;
}
// this is the function for displaying the star onscreen
displayStar = function(cameraView, focalLength){
var x = this.x - cameraView.x;
var y = this.y - cameraView.y;
var z = this.z - cameraView.z;
if (z < 0){
this.z += 5000;
this.x = 1500-Math.random()*6000;
this.y = 0;
x = this.x - cameraView.x;
y = this.y - cameraView.y;
z = this.z - cameraView.z;
}
var scaleRatio = focalLength/(focalLength + z);
this._x = x * scaleRatio;
this._y = y * scaleRatio;
this._xscale = this._yscale = 100 * scaleRatio;
this.swapDepths(Math.round(-z));
};
// define array to hold the objects in the scene
objectsInScene = new Array();
// loop through and create 6 stars randomly in the scene
for (i=1; i<=6; i++){
attachedObj = theScene.attachMovie(“star”+String(i), “star”+String(i), theScene.depth + String(i));
attachedObj.x = 250 - Math.random()500;
attachedObj.y = 0;
attachedObj.z = i500;
attachedObj.onPress = selectStar;
attachedObj.display = displayStar;
objectsInScene.push(attachedObj);
}
// function controlling the camera ease and all displaying
// for objects in the objectsInScene array
easeToTarget = function(){
// ease each camera point to its target point
cameraView.x += (cameraView.target.x - cameraView.x)/5;
cameraView.y += (cameraView.target.y - cameraView.y)/5;
cameraView.z += (cameraView.target.z - cameraView.z)/5;
// run the display function for each object in objectsInScene array
for (var i=0; i<objectsInScene.length; i++){
objectsInScene*.display(cameraView, focalLength);
}
};
theScene.onEnterFrame = easeToTarget;