View Full Version : mouse effect????
apache13
04-30-2003, 07:28 PM
How did they accomplish the effect on the first page. As you move up and down three pictures appear depending on were the mouse is.
http://www.bitasaviss.com/wo_intro.cfm
linckx
04-30-2003, 07:57 PM
that's letting a movieclip play according to the _y value of the mouse...
I don't know if you're familiar with actionscript...
I'm going to try that later on this evening, but knowing myself I won't be able to...
shouldn't be that hard though...
I'll keep you posted ;)
b.t.w.
welcome to as.org
robin
linckx
04-30-2003, 08:10 PM
got it!
and it's easy as hell:
//set a variable called mousey, and put the rounded values of the _y position of the mouse in it.
mousey=math.floor(_ymouse);
//myMc is an mc with as many frames as your height, or the height you want it to be checked.
_root.myMc.gotoAndStop(mousey);
of course if you want to go further, you could use minimum and maximum values etc... by using if statements.
friendly greetings
robin
apache13
04-30-2003, 08:26 PM
Thank you so much for taking the time to help me-but unfortunately I though this would be an easy thing- but when it comes to action scripting I am a bafoon. If you have the time to explain further I would appreciate it. Thanks
linckx
04-30-2003, 08:44 PM
I'm gonna explain this like you've never written one line of script before, so don't be offended if I treat you like a baby while being one myself ;):p
to start, draw for example a cube.
press f8
now you give it a name, and save it as Movieclip
now flash takes you in the Movieclip
press f8 again
now save it as a graphic with another name.
what you've done so far is to put a graphic (for tweening) into an mc (for the movement).
then in the Movieclip, make sure you're not in the graphic though, make a new keyframe (f6) and drag it 100 frames further.
right click the frames in between the keyframes and select 'create motion tween'.
now scale the cube on the last keyframe to a different scale and see what happens when you press ctrl-enter (on mac that is command-enter).
you've exported your movie, but that movieclip keeps on looping.
therefore we're going to put an action in it:
make a new layer in the mc, and select the first keyframe and press f9 (actions palette). type in stop(); or select it from the left.
now you've put a stop action on that mc. It won't loop anymore.
so far this is really basic stuff. If you allready had troubels with this, I suggest you start on reading tutorials etc for beginners, to make sure you don't have to think too much by doing these things anymore.
we move on:
on your stage, make a new layer, select the first keyframe, and type those two rules of code in it.
the mousey is a variable
math.floor is used to round the given integers down to a whole digit.
the integers are given by the _ymouse, a standard command in flash that follows your mouse around.
now you need to tell your movieclip to go to the frame that is equal to the mouseposition. To adress mc's out of actionscript they need instancenames: select your mc, and go to the propertiespalette. there you will see a little field for text.
name it myMc
you'll see that name is used in the second line of code:
literally you say there:
_root: go to the very very start of my movie
. : used to separate
myMc: there you have your mc
gotoAndStop() : go to the frame between the brackets and stop there
mousey: that variable we declared in the first line.
now it should work.
just adapt the number of frames to the height of your movie et voila!
I must say that it is quite unusual for people to explain this close in detail... but they do in tutorials.
take a peek here: the actionscript.org tutorials (http://www.actionscript.org/tutorials.shtml)
hope this helps
friendly greetings
robin
apache13
04-30-2003, 09:21 PM
Oh my god- you are amazing- Thank you so much- really did not expect a line by line explanation. I attached my file because I followed what you said but it does not seem to work. Thanks again - you Rock
linckx
04-30-2003, 09:27 PM
can't tell you why it isn't working...
here's the little fla I made, just change the graphic antd it should work...
robin
apache13
04-30-2003, 09:30 PM
can you export it in flash 5- thanks again so much
linckx
04-30-2003, 09:33 PM
there you go!
apache13
04-30-2003, 09:41 PM
Thanks again- did I say you rock:)
linckx
04-30-2003, 09:43 PM
well, to be honest, I was glad there finally was a question I could salve myself ;)
happy flashing mate!
robin
Thanks linckx,
That was nice of you to go through so much trouble to help out. Marcus had a similar effect on his site where the alpha value would change according to the _x values. People were asking how he did that, but he wouldn't share the secret just yet. I'm thinking it can't be much harder than this. What do you think.
http://www.networkshadow.co.uk/page.htm
I've been using Flash for a couple of months now, so I'm probably past the bafoon stage. I'm thinking I'm up to the bonehead stage by now.
:D
linckx
05-01-2003, 09:05 PM
hi vman,
I was one of those people who asked too :) actually the first; really wanna know that, but I respect him keeping it for himself.
throwing it here is a risk that when you're finally done, someone else allready got an award for it, and try to claim it then...
the problem wasn't the alpha, that you can easily do with this script... the difficulty is the gradient in the alpha...
and that is way beyond my knowledge... which is that of the baffoon you mentioned ;)
robin
robin,
thanks for that in depth description of the effect. also being a fellow bafoonite (and/or boneheadian), it really helps to have things like that layed out so clearly.
bafoonites unite
skee
linckx
05-02-2003, 08:13 AM
you're welcome guys :d
glad to make some people happy
enjoy the sun!
r:pbin
robin,
i downloaded your mouse position fla and been playing around with it a bit. many thanks. i am having a hard time making the mouse interaction and the mc it is controlling be smooth. even on your fla, the shape response was choppy. do you (or anyone else) know how to make the mc response not so choppy.
thanks
skee
rrottman
05-05-2003, 10:09 AM
I believe they simply made a MASK follow the _ymouse property of the _root timeline. I put together a very rough example in the attached .fla.
Obviously they added some elasticity (a lot tutorials to add this can be found ín AS's tutorial section) and they slightly moved the image while moving the mask.
Take a look at my .fla. Entire scripts are on the main timeline, frame 1 of the scripts layer.
farafiro
05-05-2003, 11:19 AM
u can do this with several ways, most important to know what you want b4 doing it
see the tuts section here and the Movies also
some cool ideas
farafiro
yeah, you are correct on that. what I want to do is be able to basically control an mc with mouse movement. as you move the mouse to the left, the mc progresses forward...if you move it to the right, it goes backwards...so the masking option (although cool) doesn't fit what I want (thanks rrottman). ideally, it would be nice to make the mc speed up with increased mouse speed, but will start with the basics first. this is an area i have yet to explore so a bit of a newbie.
skee
farafiro
05-06-2003, 07:43 AM
well, it's a bit easy but you wanna a fla or how to do it.
here is the basic idea of it and I'm sure u can do the rest
let's say that the mc has 6 frames and the movie's width is 600 pix.
so we simply get the mouse x position (_xmouse), divide it by 100 (with some rounding) and put it on an onEnterFrame function to make the MC goes to the correspondent frame
of course u can double the number if the MC has more frames ;)
farafiro,
thanks for the tips. i am trying to get it to work, but having some trouble. will go search for an fla to help.
skee
farafiro
05-07-2003, 07:04 AM
show me what you've got 'till now
farafiro,
actually, i did get it to work without using the onEnterFrame approach.
what I have now is what was done above.
in frame one
mousey = math.floor(_ymouse);
_root.animation.gotoAndStop(mousey);
then frame 2 just loops back to one. i noticed choppyness is related to frame rate. dat is it for now. i just need to play with things to smooth it out.
farafiro
05-08-2003, 06:20 AM
that, hmmmm lag or whatever for the farme's looping.
just do it within onEnterFrame or setInterval() with an updateAfterEvent() ;)
farafiro,
the onEnterFrame approach works nicely. thanks. now it seems to run independent of the frame rate. all i did was
_root.myMC.onEnterFrame = function() {
mousey = math.floor(_ymouse);
_root.myMc.gotoAndStop(mousey);
};
now, being that myMC is only 100 frames, the mouse function only works on the top part of the swf (if that makes sense). I spaced everything out in the mc to make it 300 frames which gives more flexibility. any other suggestions on how to deal with that. would like it so that no matter how the swf is sized, the scroll range of the mouse is top to bottom (or left to right). haven't tried the setInterval way yet.
thanks again farafiro
skee
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.