Be a Supporter!

Moving direction with mouse movemen

  • 431 Views
  • 9 Replies
New Topic Respond to this Topic
Blordow
Blordow
  • Member since: Dec. 17, 2003
  • Offline.
Forum Stats
Supporter
Level 27
Artist
Moving direction with mouse movemen 2007-10-04 17:53:23 Reply

Hello.

I am making a interactive map that zooms in when you click the stage and you can navigate around the map by moving your mouse in any direction and the map would follow.

How can I achieve this? I haven't actually started on this project but anything to help get me started on would be much appreciated.

Cheers


BBS Signature
MrCrinkle
MrCrinkle
  • Member since: Jan. 26, 2004
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Moving direction with mouse movemen 2007-10-04 18:01:09 Reply

Use a v-cam. Here's a link. That should help you get started, if you need to know the actionscript for the movement just ask.


If you are reading this then you must be really bored.

BBS Signature
Kart-Man
Kart-Man
  • Member since: Jan. 7, 2007
  • Offline.
Forum Stats
Member
Level 27
Blank Slate
Response to Moving direction with mouse movemen 2007-10-04 18:02:57 Reply

You can use a vcam to do something like that... basically, it's a virtual camera that shows what is displayed under it. Link to Download. It's what Adam Phillips uses.

Then, you can make some sort of boolean on it that resizes the vcam with _xscale and _yscale or something like that.

on (mouseDown) {
if (boolean == true) {
boolean = false;
}else if (boolean == false) {
boolean = true;
}
}
onClipEvent (enterFrame) {
if (boolean) {
_xscale+=5;
_yscale+=5;
}else if (!boolean) {
_xscale -=5;
_yscale-=5;
}
}

Then, of course, you set limits to it to prevent it from going past a certain _yscale or _xscale.

if (_yscale < 100) {
_yscale = 100;
}

and such.

For the moving with the mouse, you can have something like:

onClipEvent (enterFrame) {
_x = _root._xmouse;
_y = _root._ymouse;
}

Note that all of this is untested, and if it does work, you can easily simplify and compact it. It's just an example.


postcount +=1;
Newgrounds Photoshop Headquarters || Don't use MS Paint! Use Aviary!
SING US A SING YOU'RE THE PIANO MAN

BBS Signature
Blordow
Blordow
  • Member since: Dec. 17, 2003
  • Offline.
Forum Stats
Supporter
Level 27
Artist
Response to Moving direction with mouse movemen 2007-10-04 18:36:19 Reply

I can't find the Vcam .fla download on that site. Where is it?


BBS Signature
MrCrinkle
MrCrinkle
  • Member since: Jan. 26, 2004
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Moving direction with mouse movemen 2007-10-04 20:25:26 Reply

You don't have to download anything, just copy the code from the site and put it in a movie clip. It's that simple!


If you are reading this then you must be really bored.

BBS Signature
Blordow
Blordow
  • Member since: Dec. 17, 2003
  • Offline.
Forum Stats
Supporter
Level 27
Artist
Response to Moving direction with mouse movemen 2007-10-07 16:21:48 Reply

Could someone help me again?

I can't get this thing to work so that the cursor moves in the direction of it's movement. If you get me?

I also need a zoom code, when you click and hold the image zooms in closer.

Thanks in advance :)


BBS Signature
sandypaw
sandypaw
  • Member since: Jun. 28, 2007
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Moving direction with mouse movemen 2007-10-07 16:35:52 Reply

At 10/7/07 04:21 PM, Blordow wrote: Could someone help me again?

I can't get this thing to work so that the cursor moves in the direction of it's movement. If you get me?

I also need a zoom code, when you click and hold the image zooms in closer.

Thanks in advance :)

Thats just:
onClipEvent (mouseDown) {
_root.thing._xscale -= 5;
_root.thing._yscale -= 5;
}
Something like that? :P


=3

Blordow
Blordow
  • Member since: Dec. 17, 2003
  • Offline.
Forum Stats
Supporter
Level 27
Artist
Response to Moving direction with mouse movemen 2007-10-07 16:41:21 Reply

That didn't work :(


BBS Signature
Moo12321
Moo12321
  • Member since: Aug. 26, 2007
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Moving direction with mouse movemen 2007-10-07 20:15:46 Reply

I was making an interactive map too just like the one your talking bout
heres mine:
Interactive Map (Alpha)

Shift zooms in and Control zooms out, ill let the scroll wheel do that too sometime.

Anyways, back to the question.

Put this code on the first frame of your flash document

_root.onEnterFrame = function(){
positionX = _root._xmouse;
positionY = _root._ymouse;
stage._x = stage._x + (positionX - stage._x)/4
stage._y = stage._y + (positionY - stage._y)/4
}

Change the "stage" to whatever you named your vcam, you can change the 4 to adjust how fast the camera moves.

For zooming I forget what I did. The file is on my other comp and im too lazy to transfer. Just do something like

if (Key.isDown(Key.SHIFT) {
stage._xscale =* 1.1
stage._yscale =* 1.1
}

I think that should work, I cant guarentee, Ill check as soon as I can get on my other computer.

Coolio-Niato
Coolio-Niato
  • Member since: Jun. 30, 2005
  • Offline.
Forum Stats
Member
Level 28
Blank Slate
Response to Moving direction with mouse movemen 2007-10-07 21:24:00 Reply

At 10/7/07 04:41 PM, Blordow wrote: That didn't work :(

What he said does work. I know for a fact....

how inexperienced are you with AS?