Solved

Loop on Rollover

Posted on 2002-04-27
12
659 Views
Last Modified: 2012-05-04
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!!!
0
Comment
Question by:neurolepticdotde
  • 3
  • 3
  • 2
  • +2
12 Comments
 
LVL 23

Expert Comment

by:Zeffer
Comment Utility
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
 
LVL 7

Expert Comment

by:ssdesign
Comment Utility
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
 
LVL 7

Expert Comment

by:ssdesign
Comment Utility
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
 
LVL 7

Expert Comment

by:ssdesign
Comment Utility
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
 
LVL 23

Expert Comment

by:adilkhan
Comment Utility
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
 
LVL 23

Expert Comment

by:adilkhan
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:neurolepticdotde
Comment Utility
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
 
LVL 23

Expert Comment

by:Zeffer
Comment Utility
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
 
LVL 23

Expert Comment

by:Zeffer
Comment Utility
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
 
LVL 1

Accepted Solution

by:
chill0123 earned 75 total points
Comment Utility
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
 
LVL 1

Expert Comment

by:chill0123
Comment Utility
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
 

Author Comment

by:neurolepticdotde
Comment Utility
thanx, it works perpectly!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now