View Full Version : Follow mouse
TheVisionary
01-19-2009, 05:58 PM
I am trying to make the line follow the mouse along the x position. It's not working. Can someone fix my poor AS code. I want it to follow the x position along the lines.
http://www.yousendit.com/download/WnBRYlJWaTEwZ2tLSkE9PQ
orange gold
01-20-2009, 02:04 AM
your code is fine.... when you made the whole thing a symbol you set the regestration point to the left side and not the center...
to see what im talking about. on the main timeline scoot the whole ruler over so that the ruler's 2 inch mark line is on the very far left side of the "white box" in the back ground and hit play and it will line up correctly...
youll just have to redo the thing and this time when you make it a symbol make sure all symbols are aligned in the center
orange gold
01-20-2009, 02:13 AM
you could replace your code with something like this... not detecting the _root mouse x position but then it will slide over at a speed of 5fps every time...
onClipEvent (load) {
this.onEnterFrame = function() {
var NewX = _root._xmouse - 275
if (this._x <= NewX) {
this._x += 5
}
if (this._x >= NewX) {
this._x -= +5
}
}
}
Mazoonist
01-20-2009, 02:23 AM
You don't necessarily have to redo the whole thing. Just follow these steps:
1. double-click the ruler on the stage to go into its edit mode
2. inside ruler, on its timeline, unlock the layer named "Bottom"
3. click on the Bottom layer to highlight all its contents
4. click on the selected shape somewhere. You'll have to click on one of the lines directly.
5. in the properties panel, where it should now say "Shape", type in 0 for an x value.
6. click Scene1 to go back to the main timeline. Now it will work like you expect it to.
orange gold
01-20-2009, 02:32 AM
here would be the final code to set the regesitrartion point off by 275 to make it equal with the root if u dont feel like adjusting that and it will keep your speed ease...
onClipEvent (load) {
this.onEnterFrame = function() {
var NewX = _root._xmouse - 275
if (this._x <= NewX) {
this._x += +(NewX - this._x)/6
}
if (this._x >= NewX) {
this._x += +(NewX - this._x)/6
}
}
}
glad i could help it was fun for me to mess around with
~ Orange gold
also jsut pm me if you need any more help
TheVisionary
01-20-2009, 03:34 AM
I can't believe I missed the registration point. Guess I will be spending more time in here ;)
Thank you both.
orange gold
01-20-2009, 03:51 AM
anyways... did the code work?... with the most recent code i posted you dont even have to fix your registration point
~ OG
TheVisionary
01-20-2009, 04:03 AM
Yep it worked perfectly.
Thanks dude
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.