Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Movement with Rollover in Flash


  • Please log in to reply

#1
Hitokage

Hitokage

    Member

  • Member
  • PipPip
  • 76 posts
on (rollOver){
	yTHSS = getProperty(_root.thss_movie, _x);
	trace(_root.thss_movie._x);
	if(_root.thss_movie._x > -500){
		trace("I'm in the while loop!");
		setProperty(_root.thss_movie, _x, yTHSS-15);
	}
}

All I need is for the following to happen: user rolls over the button, and the movie clip continues to move by 15 pixels increments until the user rolls off of the button.

I tried setting up a while loop (remove the IF above for WHILE) and it just blew up. I understand why, but I'm not sure how to fix this problem.

Can anyone help?
  • 0

Advertisements


#2
Ax238

Ax238

    Tech Staff

  • Technician
  • 1,323 posts
Hello Hitokage,

It's been a little while since I've used actionscript, but let me give it a go. It looks like you are never changing the yTHSS variable, so it is always resetting the y value of the movie object to 15 pixels less than it was originally. Slightly modified, the code would read as follows (including the while):
on (rollOver){
	trace(_root.thss_movie._x);
	while(_root.thss_movie._x > -500){
		trace("I'm in the while loop!");
		yTHSS = getProperty(_root.thss_movie, _x);
		setProperty(_root.thss_movie, _x, yTHSS-15);
	}
}
This I think should do the trick.

Perhaps you could take advantage of the on (rollOut) function if needed as well.

Hope this helps,

Ax
  • 0

#3
Hitokage

Hitokage

    Member

  • Topic Starter
  • Member
  • PipPip
  • 76 posts
Ax,

That is getting closer to what I want, but now it is just going ZOOM. It goes through that while loop so fast I don't even see it happen, just jumps to the end result.

I basically have a bunch of pictures in a movie clip, and I want people to be able to scroll through them and pick one to click on.

Thanks for the help!
  • 0

#4
Ax238

Ax238

    Tech Staff

  • Technician
  • 1,323 posts
Try encapsulating the logic into a separate function, then call setInterval on the rollover and clearInterval on the rollOut.

The function would look like this (need to bring the if back in):
function scrollClip(){
	trace(_root.thss_movie._x);
	if(_root.thss_movie._x > -500){
		trace("I'm in the while loop!");
		yTHSS = getProperty(_root.thss_movie, _x);
		setProperty(_root.thss_movie, _x, yTHSS-15);
	}
}
The rest is fairly straightforward.

Regards,

Ax
  • 0

#5
Hitokage

Hitokage

    Member

  • Topic Starter
  • Member
  • PipPip
  • 76 posts
For anyone curious, this was the final code that worked:

on (rollOver){
	var intervalID;
	intervalID = setInterval( scrollClip, 200, "setInterval happens" );

	function scrollClip() {
	trace(_root.thss_movie._x);
	if (_root.thss_movie._x>-500 && _root.thss_movie._x < 318.65) {
		trace("I am in the function scrollClip.");
   		 yTHSS = getProperty(_root.thss_movie, _x);
   		 setProperty(_root.thss_movie, _x, yTHSS+30);
   	 }
	}
}

on(rollOut){
	clearInterval( intervalID );
	trace("Rolled Out!");
	
}

Thank you kindly, Ax! Worked perfect!
  • 0

#6
Ax238

Ax238

    Tech Staff

  • Technician
  • 1,323 posts
:) Looks good to me, glad you got it working! You're welcome, anytime.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP