all groups > flash actionscript > june 2006 >
You're in the

flash actionscript

group:

mouse and circle


Re: mouse and circle Rothrock
6/6/2006 7:27:37 PM
flash actionscript:
moose and squirrel?

You can't ? at least not as you have presented it. The mouse sits on the
user's desk and Flash can't "reach out and grab" their hand.

It is possible to restrict the ball to only being dragged wihin the circle. Is
that what you want?
mouse and circle Dave
6/6/2006 8:03:28 PM
Hello,

I have a circle and inside i have a ball
I would with my mouse dont get out the circle when I move

could you tell me how can i do please
I hope you undertand me

thank you

Re: mouse and circle Dave
6/6/2006 9:33:44 PM
Hello,

It's what I want
If you can give me the script THANK YOU

"Rothrock" <webforumsuser@macromedia.com> a écrit dans le message de news:
e64kv9$ott$1@forums.macromedia.com...
[quoted text, click to view]

Re: mouse and circle Rothrock
6/6/2006 11:17:28 PM
Please do you have some patience? I do have a day job and can't answer
everything immediately. In the two hours since your first response what have
you done to answer your question? Remember that everybody here is a volunteer
and nobody is paid or required to answer anything.

That being said. Create a circle movieclip put it on your stage with the name
myCircle. Make a little ball movieclip and put it on the stage with the name
ball. Then put this code on the frame. There you go!

ball.onPress = function() {
this.startDrag(false);
var cX = myCircle._x;
var cY = myCircle._y;
var radius = myCircle._width/2;
this.onEnterFrame = function() {
var curX = myCircle._xmouse;
var curY = myCircle._ymouse;
var dist = Math.sqrt(curX*curX+curY*curY);
if (dist>radius) {
var angle = Math.atan2(curX, curY);
this._x = radius*Math.sin(angle)+cX;
this._y = radius*Math.cos(angle)+cY;
}
};
};
ball.onRelease = ball.onReleaseOutside=function () {
this.stopDrag();
delete this.onEnterFrame;
};
Re: mouse and circle Dave
6/6/2006 11:29:44 PM
please do you have a solution ?
thank you

"Dave" <frsingles@ifrance.com> a écrit dans le message de news:
e64lcn$pfj$1@forums.macromedia.com...
[quoted text, click to view]

Re: mouse and circle Rothrock
6/7/2006 12:04:56 AM
I forgot to mention that the myCircle movieclip should have the registration
point at the center of the circle. Also I don't know what I was thinking. I
like this version of the code much better. It is much smoother.

ball.onPress = function() {
var cX = myCircle._x;
var cY = myCircle._y;
var radius = myCircle._width/2;
this.onMouseMove = function() {
var curX = myCircle._xmouse;
var curY = myCircle._ymouse;
var dist = Math.sqrt(curX*curX+curY*curY);
if (dist>radius) {
var angle = Math.atan2(curX, curY);
curX = radius*Math.sin(angle);
curY = radius*Math.cos(angle);
}
this._x=curX+cX;
this._y=curY+cY;
updateAfterEvent();
};
};
ball.onRelease = ball.onReleaseOutside=function () {
delete this.onEnterFrame;
};
Re: mouse and circle Rothrock
6/7/2006 7:13:58 PM
I'm at work and won't be able to work on this for quite awhile. But what is the
fun of having somebody else do it all for you?

It is all there for you. First work on making it work for one eye.

Hint#1. The size of myCircle should be fairly small compared to the size of
ball.

Hint#2. I'm guessing you also want a rotational component? If so look up
Math.atan2() in the help files. It is giving the angle between the center of
the circle and the pointer. So just a little bit of magic and you will have a
value to set for _rotation.

Hint#3. Take all the stuff in the onMouseMove and make it a function that can
be called for each eye.

Good luck. I will check back but don't know when I will have time to work on
this.
Re: mouse and circle Dave
6/7/2006 8:17:00 PM
Hello

Thank you it's good solution
I would like to do with this two eyes ;) and I would like to move the pupul
with mouse
I canto do that :(
please could you help me ?

"Rothrock" <webforumsuser@macromedia.com> a écrit dans le message de news:
e65578$f29$1@forums.macromedia.com...
[quoted text, click to view]

AddThis Social Bookmark Button