Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 988 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Flash and Actionscript :

I Doubt this can be done......

Thread title: I Doubt this can be done......
Closed Thread    
    Thread tools Search this thread Display Modes  
10-18-2008, 07:25 AM
#1
le_douche is offline le_douche
Status: I'm new around here
Join date: Oct 2008
Location:
Expertise:
Software:
 
Posts: 1
iTrader: 0 / 0%
 

le_douche is on a distinguished road

  Old  I Doubt this can be done......

so i bought this code (im an noob) so i could do this layered movement illusion, and I applied this code to one of the layers that has a looping movie with a motion guide, and every time it restarts its loop, the object moves 5 pixes or so away from the mouse. It gets quite annoying, and eventually it moves itself off the stage of my swf; to the point where i can no longer use the movie clip which i rely on for navigation

I have a feeling it has to do with the onEnterFrame

Is there any way to modify the code so it wont do that anymore?

Here is the code below:

Code:
//Set limits of image motion (note that negative values will change direction of image motion):
var y_limit:Number = 60;
var x_limit:Number = 90;

//Set speed of motion (large numbers = slower speed, if this is set to 1, motion will be instantaneous)
//DO NOT SET TO A VALUE LESS THAN 1.
var speed:Number = 15;


//THE FOLLOWING DOES NOT NEED TO BE MODIFIED:
//get original position:
var origx = this._x;
var origy = this._y;

onEnterFrame = function(){
	
	//calculate goal coordinates based on mouse position:
	goalx = origx - (((_parent._xmouse-Stage.width/2)*x_limit) / (Stage.width / 2));
	goaly = origy - (((_parent._ymouse-Stage.height/2)*y_limit) / (Stage.height / 2));
	
	//adjust position of image gradually:
	this._x += (goalx - this._x)/speed;
	this._y += (goaly - this._y)/speed;
	
}

11-09-2008, 04:49 PM
#2
derek lapp is offline derek lapp
Status: design rockstar
Join date: Jan 2005
Location: guelph, ontario
Expertise:
Software:
 
Posts: 2,246
iTrader: 0 / 0%
 

derek lapp is on a distinguished road

  Old

it moves away from the mouse because you tell it to.

this._x += (goalx - this._x)/speed;

moves the object along the x axis. the only thing onEnterFrame does is take the limits you set above and apply them to the object. if you want to stop it from moving along the x axis, just comment out that line.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed