Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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