Jump to content


Photo

How to stop Scrolling Thumbnails


  • Please log in to reply
15 replies to this topic

#1 Jas

Jas

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 13 June 2007 - 03:13 AM

Hi everyone,

I can't seem to figure out how I am going to code the thumbnails to stop scrolling when the mouse is rollover over the icons.

Each thumbnail is a movieclip of an image and on each of the thumbnails the code below has been assigned to it:

onClipEvent(enterFrame) {
_x=_x+4;
if(_x>=657.3){
_x=-55;
}
}

Does anyone know how I can get the thumbnails to stop scrolling when the mouse is rolled over one of the thumbnails?

#2 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 13 June 2007 - 09:08 AM

change your code to use:

this.onEnterFrame = function(){
move();
}
this.onRollOver = function(){
delete this.onEnterFrame;
}
this.onRollOut = this.onReleaseOutside = function(){
 this.onEnterFrame = function(){
move();
}
}
function move(){
_x=_x+4;
if(_x>=657.3){
_x=-55; 
}

That should take care of it.

#3 Jas

Jas

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 13 June 2007 - 09:35 AM

I made the change but I keep getting this error:

**Error** Symbol=panel, layer=Layer 1, frame=1:Line 1: Statement must appear within on/onClipEvent handler

Edited by Jas, 13 June 2007 - 09:37 AM.


#4 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 13 June 2007 - 11:20 AM

Put the code inside the mc rather than on it. Its bad practice to put code on the timeline, but even worse practice to put it on the movieclip or button element rather than on the timeline.

Just make a new layer inside your mc and put the code of hte first keyframe of this layer.

#5 Jas

Jas

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 14 June 2007 - 02:44 AM

Ok, I did that and the thumbnail you rollover stops. But the other thumbnails still scroll behind it. I want it so that they all stop scrolling when one of the thumbnails are moused over.

#6 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 14 June 2007 - 10:36 AM

Ok, this is kind of hacky -- but without getting into objects, proper coding, classes and all that jazz, this will do what you need.

if(_parent.btnArr == undefined){
	_parent.btnArr = new Array();
}
_parent.btnArr.push(this);

this.onEnterFrame = function(){
	move();
}
this.onRollOver = function(){
	for(var ii:Number = 0; ii < _parent.btnArr.length; ii++){
		delete _parent.btnArr[ii].onEnterFrame;
	}
}
this.onRollOut = this.onReleaseOutside = function(){
	for(var ii:Number = 0; ii < _parent.btnArr.length; ii++){
		_parent.btnArr[ii].onEnterFrame = function(){
			move();
		}
	}
}
function move(){
	_x=_x+4;
if(_x>=657.3){
	_x=-55;
}

This code will add each button into an array, then on rollover loop through the array and apply the same code to each button. On rollout it will do the same. I didn't test the code at all, but it should work. Let me know how it goes.

#7 Jas

Jas

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 14 June 2007 - 11:04 AM

Ok, all the thumbnails stop when you rollover one of them but as soon as you rollout they don't continue scroll again.

Edited by Jas, 14 June 2007 - 11:07 AM.


#8 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 14 June 2007 - 11:10 AM

Opps, thats what I get for not testing the code :blink:
Didnt close the move function, so it produced an error, and I forgot the move is a reserved word in flash, so I changed it to animate.

if(_parent.btnArr == undefined){
	_parent.btnArr = new Array();
}
_parent.btnArr.push(this);

this.onEnterFrame = function(){
	animate();
}
this.onRollOver = function(){
	for(var ii:Number = 0; ii < _parent.btnArr.length; ii++){
		delete _parent.btnArr[ii].onEnterFrame;
	}
}
this.onRollOut = this.onReleaseOutside = function(){
	for(var ii:Number = 0; ii < _parent.btnArr.length; ii++){
		_parent.btnArr[ii].onEnterFrame = function(){
		   this.animate();
		}
	}
}
function animate(){
	_x=_x+4;
	if(_x>=657.3){
		_x=-55;
	}
}


#9 Jas

Jas

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 15 June 2007 - 02:46 AM

I got the error when I copied the code over the first time I tried it, so I closed it. But changing the move function to animate has made no difference :o

#10 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 15 June 2007 - 07:55 AM

What error are you getting? The code works perfectly on my machines.

#11 Jas

Jas

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 15 June 2007 - 08:39 AM

I'm not getting an error. The problem is the same as before. All the thumbnails stop when you rollover one of them but as soon as you rollout they don't continue scroll again. They stop completely even after you have rolled out.

#12 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 15 June 2007 - 09:36 AM

Check the fla I'm using and compare that to yours.

Attached Files



#13 Jas

Jas

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 15 June 2007 - 10:04 AM

Yeah, it is. I just don't get it. So strange! May have to start a new one. :(

#14 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 15 June 2007 - 11:07 AM

If it works in my file and not in yours just make sure you have all the parts of the code, and all the movieclips are setup the same way. I'm also using flash 8/as2.

#15 Jas

Jas

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 18 June 2007 - 03:30 AM

This might seem strange but when I started again, everything began to work fine! It must have been a silly little thing that must have caused it not to work properly. Well, it works now so that's all that matters ;)

Thanks for your help. Much appreciated! :o

#16 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 18 June 2007 - 08:22 AM

np Jas, glad you got things working. Let me know if theres anything else I can help you with.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users