Menu moving based on mouse position

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 10477 Views - Last Post: 13 December 2007 - 01:00 PM

#1 cherva   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 14-April 07

Menu moving based on mouse position

Posted 07 December 2007 - 05:39 AM

Please help me to make a menu of 3 pics which are moving (up and down) based on the mouse position over the movie. I don't have an idea how to do that with ActionScript :( fla files are accepted too :rolleyes:

Is This A Good Question/Topic? 0
  • +

Replies To: Menu moving based on mouse position

#2 DilutedImage   User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: Menu moving based on mouse position

Posted 07 December 2007 - 10:34 AM

There are many tutorials that explain how to do that.

What Flash Player version are you targeting?

The simplest way to do it is to create two invisible buttons (one top, and one bottom), and then write some functions to change the images' y position when the buttons are rolled over. Of course, those functions will need to check the current y position first (use an if statement), to ensure that they stop where you want them to.

If you really want to get tricky with it though, then you could write a function to handle the enterFrame event (or onEnterFrame), which checks the y position of the mouse compared to the vertical center, and then moves the images based on that difference and a multiplier (causing it to be a faster scroll as the mouse gets further from the center). Of course, you'll still need to ensure that your images stop where you want them to.

2

View Postcherva, on 7 Dec, 2007 - 05:39 AM, said:

fla files are accepted too


Make an attempt first, and we're happy to help you fix it. This isn't a place to get free Flash work done though. :D
Was This Post Helpful? 0
  • +
  • -

#3 cherva   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 14-April 07

Re: Menu moving based on mouse position

Posted 07 December 2007 - 12:47 PM

Can't you give me some source at least ? Or Give me a link to a tutorial for my problem
Was This Post Helpful? 0
  • +
  • -

#4 DilutedImage   User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: Menu moving based on mouse position

Posted 07 December 2007 - 02:29 PM

View Postcherva, on 7 Dec, 2007 - 12:47 PM, said:

Can't you give me some source at least ?

At least? You say that as if I'm required to help you. I'm a member here so that I can help people; not do free work. If you'd like me to do all the work for you, then you can pay the $500 day rate that my clients pay.

Or, you can attempt to do this yourself, and then post any code you're having a problem with; I'd be happy to help you fix it. If the steps I've described don't make sense to you though, then you should read the first chapter of the Flash manual (accessible via the help menu), so that you can learn the basics of Flash.


View Postcherva, on 7 Dec, 2007 - 12:47 PM, said:

Or Give me a link to a tutorial for my problem

Sure .. Here ya go: Google

This post has been edited by DilutedImage: 07 December 2007 - 02:30 PM

Was This Post Helpful? 0
  • +
  • -

#5 cherva   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 14-April 07

Re: Menu moving based on mouse position

Posted 08 December 2007 - 12:38 PM

DilutedImage why are you replying to me when you don't want to help me ? What ?! I can't ask something I have no idea how to do it ? And I know google I've asked for a link to the tutorial for my problem not to google !!!
Was This Post Helpful? 0
  • +
  • -

#6 DilutedImage   User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: Menu moving based on mouse position

Posted 08 December 2007 - 01:02 PM

I would like to help you. But if you haven't made an attempt yourself, then it's not helping. In fact, giving you all the source code, with no effort on your part, would only encourage laziness.

What you're wanting to do is actually very easy for anybody with even the most basic Flash skills. If you don't know anything about Flash though, then you'll need to start with something easier (like the examples in the Flash manual).

And before getting so defensive, did you even bother to click on the link I provided? It has a few very good tutorials included in the results. Read through a couple of them; they have the free source code you're looking for.
Was This Post Helpful? 0
  • +
  • -

#7 cherva   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 14-April 07

Re: Menu moving based on mouse position

Posted 08 December 2007 - 01:09 PM

I know a fair amount of flash. I just need some directions for the ActionScript part
Was This Post Helpful? 0
  • +
  • -

#8 DilutedImage   User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: Menu moving based on mouse position

Posted 08 December 2007 - 01:33 PM

These are the steps that need to be accomplished in ActionScript, assuming that your images all live within a single MovieClip, and you've created two invisible buttons that have been placed outside of that movie clip:

- Create a function that decreases the MovieClip's y position, and include an if statement to ensure that the y coordinate has not gotten too small.
- Create a function that increases the MovieClip's y position, and include an if statement to ensure that the y coordinate has not gotten too big
- Create a rollOver event handler for the top button, that sets the MovieClip's enterFrame handler to the function that decreases y position
- Create a rollOver event handler for the bottom button, that sets the MovieClip's enterFrame handler to the function that increases y position
- Create a rollOut event handler for the top button, that removes the MovieClip's enterFrame handler
- Create a rollOut event handler for the bottom button, that removes the MovieClip's enterFrame handler
- Publish your swf
Was This Post Helpful? 0
  • +
  • -

#9 cherva   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 14-April 07

Re: Menu moving based on mouse position

Posted 09 December 2007 - 03:07 AM

Ok here is my menu for now, but I can't make it stop on rollout of the button

Attached File(s)


This post has been edited by cherva: 09 December 2007 - 03:09 AM

Was This Post Helpful? 0
  • +
  • -

#10 DilutedImage   User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: Menu moving based on mouse position

Posted 09 December 2007 - 01:42 PM

Interesting. .. Perhaps the attached solution might work better. The initialization layer has the variables you need to change the movement start/stop points, as well as the speed.

Why are you targeting Flash Player 5 though? If you're looking for backwards compatibility, targeting Flash Player 7 is more than sufficient, and will allow you to use ActionScript 2 and the MX framework.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#11 cherva   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 14-April 07

Re: Menu moving based on mouse position

Posted 10 December 2007 - 04:26 AM

OMG Am I an idiot or what ? Thanks A LOT (bow) :^:
Was This Post Helpful? 0
  • +
  • -

#12 DilutedImage   User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: Menu moving based on mouse position

Posted 10 December 2007 - 12:12 PM

Not an idiot at all. There are still a lot of Flash 4 articles returned high within search results, though they aren't good for much more than historical record. Can't blame you for that. You put an effort in, and that's what counts.

Attached is a Flash 7 version of the same file. This time though, all of the code has been moved to a single frame (much easier to follow), and the code has been cleaned up a little.

Also included is a "proper" version of the Flash 7 version. This file contains strong data typing (:Number, :String), function return typing (:Void), and adds and removes the onEnterFrame handler as needed (so that it's only running when needed).

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#13 cherva   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 14-April 07

Re: Menu moving based on mouse position

Posted 11 December 2007 - 11:35 AM

I like the first one, but I have another little problem: I moved the layers in a movie clip and the ring stopped moving I suppose I have to change the _root, but to what ? :blink:

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#14 DilutedImage   User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 646
  • Joined: 20-November 06

Re: Menu moving based on mouse position

Posted 11 December 2007 - 12:13 PM

Yep; you'll need to give that MovieClip an instance name, and re-path those variable calls. It really is a bad idea to continue with ActionScript 1 though. AS2 is just so much easier to work with, and far more flexible. Not to mention, that code really should all be in one place. Spreading the code throughout the objects can really make it a hassle to move things around.
Was This Post Helpful? 0
  • +
  • -

#15 cherva   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 16
  • Joined: 14-April 07

Re: Menu moving based on mouse position

Posted 11 December 2007 - 01:20 PM

How exactly to re-path them ? If my instance name is menu2 I tried to change all _root.XXX to _menu2.XXX and to menu2_XXX but still not working ? Please be more specific and give on expampe (it will be a better way to explain it to me )
EXAMPLE: change _root. ot xxx. :)

This post has been edited by cherva: 12 December 2007 - 06:00 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2