Loop on Rollover

Hi,

I would like to get automatically start a pan of an object(a picture etc.) when the mouse rolls over the image and stops when your mouse rolls off the button. I know I need to use a loop, but can't get it to work.

Does anybody have any ideas how to get a loop to start running on mouse rollover and stop on rollout?

Thanxx!!!
neurolepticdotdeAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
chill0123Connect With a Mentor Commented:
Zeffer is correct about not using a Tell Target... but I like to just reference the instance that I am using with the following code:

on (release) {
 _root.MOVIECLIPNAME.gotoAndPlay('frameLabel');
}

I also recommend not using frame numbers in case you want to change the position of the instances on the timeline...  if you label the frame, your scripts should always work anywhere on that particular timeline...

----------------------
A Solution to your Button/Animation question:

I am moving an instance named "ball" (but you could just replace ball with what every you named your image instance)

- create a simple movie clip that has 4 frames
- in the first frame put:
  stop();
  x = 0;
  y = 0;
- in the second frame put:
  stop();
- in the third frame put:
  inc = 5;   //increment of pan movement
  x = x + inc;
  _root.ball._x = x;
- in the fourth frame put:
  gotoAndPlay("loop");

next lable the 2nd frame "stop" and the 3rd frame "loop"

- give the movie clip an instance name like "panScript"
- put it on the stage

give the button you want to move the following code:

on (release, rollOver) {
     _root.panScript.gotoAndPlay("loop");
}
on (release, rollOut) {
     _root.panScript.gotoAndPlay("stop");
}

--------------

Make sure that all of your instances are named and reference correctly in your actionscript...

This code will move the instance named "ball" across the stage at an increment of 5.  You can also use another button to move the instance back across, or what every you want...

To make the image look like it is staying in place but panning to the right/left, just add a masked layer above that of the instance you are moving...

This effect will move the image, but all you will see is what is displayed in the mask area...

hope this works for you...

 
 
0
 
ZefferCommented:
I did it like this using 3 letters just to explore
the concept.

Open a new movie.
Insert/new symbol/movie (we'll call it X)
layer one..frame1.. Draw theletter A

Hit F5 at Frame 10..I've done this to slow the
whole thing down a bit..

Insert Keyframe at frame11..draw letter B
Hit F5 at 20..

Insert keyframe at 30..Draw letter C
Hit F5 at frame 30

We have our looping movie A..B..C..

Insert/New symbol/button (hotspot)
select frame 4 'HIT', and draw a rectangle
to use as the hotspot or active area of the button.

go back to the movie X and drag an instance of
the hotspot button to frame one in layer 2 and
position it over the A.

Open the action panel and insert the following code

on (rollOver){
Play O;
}

on (rollOut){
stop O;
}

on layer 2..select frame 10 and press F5 so the button is active for the same duration as the layer below..

repeat the above to make active areas for B and C

thats it.

Of course if you want to use this to pan an image
you are basically putting single images on single
frames but despite that being a lot of work it is
very do-able and is not something I had thought of
or tried myself.Thanks for the idea.
Z


0
 
ssdesignCommented:
Do this.

Create the animation to PAN a picture inside a movie clip.
Give it an instance name "pan"

Now ccreate a button that you want to work as a movie controller.
Give the following action to this button:

on (rollOver) {
    tellTarget ("_root.pan") {
        play ();
    }
}
on (release) {
    tellTarget ("_root.pan") {
        stop ();
    }
}

Thats it.
0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
ssdesignCommented:
SORRY.... there was a little error in the code above:

CCOREECT IT PLEASE.... THIS IS THE RIGHT CODE::::

on (rollOver) {
    tellTarget ("_root.pan") {
        play ();
    }
}
on (rollOut) {
    tellTarget ("_root.pan") {
        stop ();
    }
}
0
 
ssdesignCommented:
Do this.

Create the animation to PAN a picture inside a movie clip.
Give it an instance name "pan"

Now ccreate a button that you want to work as a movie controller.
Give the following action to this button:

on (rollOver) {
    tellTarget ("_root.pan") {
        play ();
    }
}
on (release) {
    tellTarget ("_root.pan") {
        stop ();
    }
}

Thats it.
0
 
Saqib KhanSenior DeveloperCommented:
Do this Lets say your Image is on Frame number 10 and your button is on frame number 1.
on Rollover {
gotoandstop 10
}
on RollOut {
gotoAndStop 1
}
0
 
Saqib KhanSenior DeveloperCommented:
just one more thing I forgot to Mention if you have a Animation on Frame 10 then try to make that Animation as a MOVIECLIP(onr frame long).
0
 
neurolepticdotdeAuthor Commented:
Hi again,

at first: thanx for the postings!!

but: to move the pic i want to use actionscript
like "on (rollover) > tell target "pic" > set property
"pic" = x_pos(variable given as: xpos = getProperty "pic" _x) +1  ... like this

the problem is: when i rollover the button, "pic" only moves one time an then it stops. What i want is that the
"pic" moves continuesly in a direction when i'm over the button. I think i have to use an actionscripting loop etc. ?? I don't know, I can't get it work.

I hope you can help me!!! Thank you!
0
 
ZefferCommented:
For a start you will have to give up 'Tell Target'
which only targets the path to the clip..it cannot
target objects..and move on to 'Method' using the 'With' Action.

'With' allows you to set and control several properties
and control actions while targeting (in this case-the movie-clip object) only once.

There is an excellent section in Flash Help to assist
you with this.

It is recommended that we stop using 'Tell Target' as
it has been made redundant by 'with'...which is more
robust and also complient to established standards.

Z


0
 
ZefferCommented:
For a start you will have to give up 'Tell Target'
which only targets the path to the clip..it cannot
target objects..and move on to 'Method' using the 'With' Action.

'With' allows you to set and control several properties
and control actions while targeting (in this case-the movie-clip object) only once.

There is an excellent section in Flash Help to assist
you with this.

It is recommended that we stop using 'Tell Target' as
it has been made redundant by 'with'...which is more
robust and also complient with established standards.

Z


0
 
chill0123Commented:
Zeffer is correct about not using a Tell Target... but I like to just reference the instance that I am using with the following code:

on (release) {
 _root.MOVIECLIPNAME.gotoAndPlay('frameLabel');
}

I also recommend not using frame numbers in case you want to change the position of the instances on the timeline...  if you label the frame, your scripts should always work anywhere on that particular timeline...

----------------------
A Solution to your Button/Animation question:

I am moving an instance named "ball" (but you could just replace ball with what every you named your image instance)

- create a simple movie clip that has 4 frames
- in the first frame put:
  stop();
  x = 0;
  y = 0;
- in the second frame put:
  stop();
- in the third frame put:
  inc = 5;   //increment of pan movement
  x = x + inc;
  _root.ball._x = x;
- in the fourth frame put:
  gotoAndPlay("loop");

next lable the 2nd frame "stop" and the 3rd frame "loop"

- give the movie clip an instance name like "panScript"
- put it on the stage

give the button you want to move the following code:

on (release, rollOver) {
     _root.panScript.gotoAndPlay("loop");
}
on (release, rollOut) {
     _root.panScript.gotoAndPlay("stop");
}

--------------

Make sure that all of your instances are named and reference correctly in your actionscript...

This code will move the instance named "ball" across the stage at an increment of 5.  You can also use another button to move the instance back across, or what every you want...

To make the image look like it is staying in place but panning to the right/left, just add a masked layer above that of the instance you are moving...

This effect will move the image, but all you will see is what is displayed in the mask area...

hope this works for you...

 
 
0
 
neurolepticdotdeAuthor Commented:
thanx, it works perpectly!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.