Solved

Loop on Rollover

Posted on 2002-04-27
12
672 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
ID: 6974086
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
ID: 6974386
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
ID: 6974388
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 7

Expert Comment

by:ssdesign
ID: 6974389
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:Saqib Khan
ID: 6974407
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:Saqib Khan
ID: 6974409
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
 

Author Comment

by:neurolepticdotde
ID: 6974694
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
ID: 6975716
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
ID: 6975720
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
ID: 6981193
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
ID: 6981194
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
ID: 6981423
thanx, it works perpectly!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Crash with shockwave flash 8 251
Rotating Adobe pdf document 4 320
Shockwave Flash Object within PowerPoint 2013 2 149
how do I install adobe flash player on my ipad Air? 4 46
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
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,…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

839 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