Topic: While pressed? / Set pivot point

Two questions:

1. Is there a way to do something only while pressed? I am making a tangram widget, where you rotate the chumby while pressing a piece to rotate the piece. Currently, I have a on(press) and an on(release) to say when to rotate a piece, but sometimes it will rotate off the mouse, and doesn't trigger a release, so it keeps rotating. Is there some way I can do while(press)?

2. Also, I was wondering if I could chage the "pivot point" of each shape to wherever the user touched when they press the shape, rather than the set place (the center).

Thanks big_smile

Re: While pressed? / Set pivot point

You might try doing on(releaseOutside) with the same thing you're doing for the on(release).

You have a couple of choices with the pivot point:

1) Do the necessary trig to move/rotate the movieclip to simulate the pivot point you want.
2) Nest the clip in another clip, move the object in the inner clip and rotate the outer clip.

Re: While pressed? / Set pivot point

on(releaseOutside) doesn't catch it either.

And I might do #2, the only problem I see is that you can't refer to stuff inside mc's, unless you do root, which I can't do with this application.
I may try to figure out the trig on #1, but it would be complicated, and may effect the CPU too much. (If I update it every frame its pressed, it could be a bit). Drawing a line 200 pixels long took a big chuck out!

Re: While pressed? / Set pivot point

Why can't you refer to things inside movieClips?  I do it all the time - you don't need _root for that, you can do paths relative to "this" or "_parent".

Re: While pressed? / Set pivot point

perhaps the question #1 is "how do I keep running the same code repeatedly while the mouse is down?"

Do something like:
pressing = false
myButton.onPress = function () { pressing = true }
myButton.onRelease = myButton.onReleaseOutside = function () { pressing = false }
onEnterframe = function(){
   if (pressing == true ){
      //run code

Hope that helps.

Pivot point--I'd just nest clips for that.

Re: While pressed? / Set pivot point

Thats exactly what I do now, and doesn't work.
It works, it just that the Release isn't triggered when it rotates outside the cursor.

Solving one of these solves the other, and I am working on the trig big_smile

Re: While pressed? / Set pivot point

what about catching the onDragOut?