Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scroll 1

Status
Not open for further replies.

kaskas

Technical User
Apr 30, 2004
6
GB
hello any one help i have a movie containing lots of images which when an image is pressed loads another movie (loadmovie) i used some code i found from here:

onClipEvent (load) {
speed = 0;
center = 225;
w = _width/1;
}
onClipEvent (enterFrame) {
speed = (_root._xmouse-center)/10;
_x -= speed;
(_x<=center-w)?(_x=center-w):null;
(_x>=center+w)?(_x=center+w):null;
updateAfterEvent();
}

when i move the mouse left or right on the stage the movie moves in turn left or right however i would like the movie only to move left and right when the mouse is directly over that movie and not when the mouse is on other parts of my stage, do i have to put these in a button and use the rollover?? or can it just be scripted
 
Add an if statement outside of your script that does the moving of the images.

Code:
if(this.hitTest(_root._xmouse, _root._ymouse, false)){
   //your code to move the images
}

This will check the mouse position against the movie clip boundaries and execute the action if the mouse is inside the clip area.

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 

May I add... no need to include updateAfterEvent() in an onEnterFrame-script

regards

tektips.gif
 
Thanks for your replies ive removed the updateafterevent() and added pixl8rs code as below but flash says that the if Statement must appear within onClipEvent handler

if(this.hitTest(_root._xmouse, _root._ymouse, false)){
onClipEvent (load) {
speed = 0;
center = 225;
w = _width/2;
}
onClipEvent (enterFrame) {
speed = (_root._xmouse-center)/10;
_x -= speed;
(_x<=center-w) ? (_x=center-w) : null;
(_x>=center+w) ? (_x=center+w) : null;
}
}

so i tried this (below) but the movie still moves where ever the mouse is on the stage?

onClipEvent (load) {
if (this.hitTest(_root._xmouse, _root._ymouse, false)) {
}
speed = 0;
center = 225;
w = _width/2;
}
onClipEvent (enterFrame) {
speed = (_root._xmouse-center)/10;
_x -= speed;
(_x<=center-w) ? (_x=center-w) : null;
(_x>=center+w) ? (_x=center+w) : null;
updateAfterEvent();
}


 
You just have the if statement in the wrong place. Try this:

Code:
onClipEvent (load) {
    speed = 0;
    center = 225;
    w = _width/2;
}
onClipEvent (enterFrame) {
    if (this.hitTest(_root._xmouse, _root._ymouse, false)) { 
    speed = (_root._xmouse-center)/10;
    _x -= speed;
    (_x<=center-w) ? (_x=center-w) : null;
    (_x>=center+w) ? (_x=center+w) : null;
    updateAfterEvent();
    }
}

Wow JT that almost looked like you knew what you were doing!
 
Oh and you should still be able to remove the updateAfterEvent().

 
opps thanks for help worked a treat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top