Forum Moderators: open
simply is its when the movie loads just place this in frame 1 of your main timeline...
path.to.clip_mc.onEnterFrame = function() {
clipspeed = (cliptarget-this._x)/6;
this._x += clipspeed;
};
//
var clipspeed:Number = 0;
var cliptarget:Number = 450;
path.to is the refeence to the clip to move which has an instance name of clip_mc
Place the clip where you want it to start from on the x axis and change the variable for cliptargert to the x co-ords wher you want it to end up
the /6 controls the speed it moves, the lower the number the faster it goes then brakes, and stops (in simple terms)
pathto.buttonname_btn.onRollover = function(){
//previous example goes here
}
sorry being a a bit thick here, I have created my four buttons... an example of one function attached:
this.upButton.onRollover = function(){
clipspeed = (cliptarget-this._x)/6;
this._x += clipspeed;
};
//
var clipspeed:Number = 0;
var cliptarget:Number = 450;
I need to target the movie clip that this is controlling, I cant quite figure out where to put it, have tried different ways.. my movie clip instance is called clipWindow
I also need to stop the movement on rollout, is it something like
this.upButton.onRollout = function(){
clipspeed = (cliptarget-this._x)/0;
this._x += clipspeed;
};
where 0 stops it ..?
One of the problems is I dont quite understand what I am asking flash to do, if Its possible for brief explanation it would be very very helpful
ZA
OK first you need to set up a callback function for the button ( //are comments )
//button function
buttonname_btn.onRollover = function(){
//now set up a call back for inertia function of //clipWindow
clipWindow.onEnterFrame = function() {
clipspeed = (arollovertarget-this._x)/6;
this._x += clipspeed;
};
}
//variables second is where the clip ends uo on x axis
var clipspeed:Number = 0;
var arollovertarget:Number = 450;
and thats it, just repeat the process for rollOut, define all functions first, then put the variables at the end of the script. so for rollover you will need to define a new target such as
var brollovertarget:Number = 200;
//in english
//on mouse over
// clip (a) rollover target is _x=450
//and on mouse out
//clip (b) rollover target is _x=200
I have added code as below, tried to make a right movement but cant work out what is changing what, so there is little chance I can work out how to make up and down and the rollout stop the action either...
//button function
this.leftButton.onRollover = function(){
//now set up a call back for inertia function of //clipWindow
clipWindow.onEnterFrame = function() {
clipspeed = (arollovertarget-this._x)/6;
this._x += clipspeed;
};
}
//button function
this.rightButton.onRollover = function(){
//now set up a call back for inertia function of //clipWindow
clipWindow.onEnterFrame = function() {
clipspeed = (crollovertarget-this._x)/6; //tried putting y in here to make up and down too
this._x += clipspeed;
};
}
//variables second is where the clip ends uo on x axis
var clipspeed:Number = 0;
var arollovertarget:Number = 650;
var crollovertarget:Number = -650; //tried putting minus in here
I have books on this stuff but still am completely confused. Can you give me any more help and explanation?
ZA