Hello! I have a problem to make the “camera” move forward instead of just stand still, without conflicting the names variables. I would be so happy if someone could help me! ’
Please:)
the code for the scene is:
// register root as environment
Object.environment = this;
// create camera object
this.cam = {x:0, y:0, z:400, dx:0, dy:0, dz:-400};
// set environmental constants
this.fl = 1000;
// create 'space' to which all words will be attached
this.createEmptyMovieClip("space",1);
// center 'space' on the stage
space._x=277.5;
space._y=256;
// a string of words related to the wind
this.somewords = "Fabian Brunnström, Mattias Jonson, Daniel Tjernström, Tomas Holmström, Nick Gross, Rice Hanson, Christian Blood, Pontus Avant";
// convert the string of words into an array of words
this.wordList = new Array();
this.wordList = this.somewords.split(",");
// create one instance for each word in the list
for (n=0;n<this.wordList.length;n++) {
// pick a word from the list
var word = Object.environment.wordList[n];
var x = random(555)-277.5;
var y = random(512)-256;
var z = random(Object.environment.fl*2)-Object.environment.fl;
// create an instance of the SpaceWord object
nombre = "word"+String(depth++);
initialization = {txtword: word, x: x, y: y, z: z};
space.attachMovie("spaceWord", nombre, depth, initialization);
}
this.onEnterFrame = function() {
// move the camera to its destination
this.cam.x+=(this.cam.dx-this.cam.x)/10;
this.cam.y+=(this.cam.dy-this.cam.y)/5;
this.cam.z+=(this.cam.dz-this.cam.z)/25;
}
stop();
it calls the movieclip spaceWord who has as code
#initclip
// constructor
function SpaceWord() {
// set up button functionality
this.btnSquare.onPress = function() {
// push the camera towards the word by setting destination just a bit in front
Object.environment.cam.dx = this._parent.x;
Object.environment.cam.dy = this._parent.y;
Object.environment.cam.dz = this._parent.z+Object.environment.fl*.9;
// disable and hide button
this.enabled = false;
this._visible = false;
};
// set continual function to render word
this.onEnterFrame = this.render;
}
// allow SpaceWord to inherit MovieClip properties
SpaceWord.prototype = new MovieClip();
// instance methods
SpaceWord.prototype.render = function() {
var zActual = Object.environment.fl+this.z-Object.environment.cam.z;
// has the object moved behind the camera?
if (zActual>0) {
// object is still visible
// calculate scale
var scale = Object.environment.fl/zActual;
// set position using camera as an offset
this._x = (this.x-Object.environment.cam.x)*scale;
this._y = (this.y-Object.environment.cam.y)*scale;
// set size
this._xscale = scale*100;
this._yscale = scale*100;
// set fog
this._alpha = 100 - 99 * zActual/Object.environment.fl*.5;
} else {
// object has moved behind camera
// reposition further down the line
this.z += Object.environment.fl*2;
// enable button
this.btnSquare.enabled = true;
this.btnSquare._visible = true;
}
};
SpaceWord.prototype.setWord = function(s) {
this.txtWord = s;
};
SpaceWord.prototype.setPosition = function(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
};
// Connect the class with the linkage ID for this movie clip
Object.registerClass("spaceWord", SpaceWord);
#endinitclip
this is a old spacetext from Jared Tarbell