PDA

View Full Version : trying to write a script that loads a movie if _x is decreasing or increasing


mentalblock
03-27-2003, 03:04 AM
I have been trying to write a scipt that enables me to load a different movie depending on what direction a parent clip is travelling along the x axis.

on an emptyClip on the main timeline I have placed this code

onClipEvent (enterFrame) {
placedude(dude);
function placedude(dude) {
this.attachMovie("dude", dude2, 1000);
}
}

\\dude is a movie I am linking too in the library.

on a movie clip on the main timeline also I have a bit of code to make it move along the x plane in a random direction

onClipEvent (load) {
_root.targetx = math.round(math.random()*1000);
}
onClipEvent (enterFrame) {
currentX = this._x;
difX = currentX-_root.targetx;
setProperty(this, _x, currentX-(difX/5));
_root.emptyClip._x = currentX;
}

I have tried attaching variations on the theme of the function placedude to try and get two clips called process2 and process to load with an attachMovie action depending on what direction the clip on th emain timeline is moving to no sucess

function placedude(){
if (this._x = this._x--) {
this.attachMovie("process2", dude, 1000);}
else {if (this._x = this._x++) {
this.attachMovie("process2", dude2, 1000);}
}}

has anybody ever done this before or knows of a bit of script that can tell which direction the asscociated clip is moving.

something that has logic along the lines off if x dir is negative then load process else if dir is positive unload process and load process2.

hope somone understands the ravings off a man about to headbutt a wall in frustration

Billy T
03-27-2003, 03:15 AM
this is close

cheers

mentalblock
03-27-2003, 03:24 AM
I had a go at trying to use a function with (i=1024; i>0; i--) that was attempting to do the same thing as yourself but I musta balls'd it up.

I can work with this, nice one BillyT

a humbled mentalblocker