Re: lingo-l dragging a non-moveable sprite
have you tried updateStage during the stilldown section. - Original Message - From: Slava Paperno [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, August 20, 2001 1:18 AM Subject: lingo-l dragging a non-moveable sprite For a couple of reasons, I don't want to make my sprite moveable, yet I do want the user to be able to move it with the mouse. So I use this script: on mouseDown me pLeftMouseOffset = the mouseH - sprite(me.spriteNum).loc[1] pTopMouseOffset = the mouseV - sprite(me.spriteNum).loc[2] if the stillDown then locLeft = the mouseH - pLeftMouseOffset locTop = the mouseV - pTopMouseOffset sprite(me.spriteNum).loc = point(locLeft, locTop) end if end mouseDown It generally works, but when you move the mouse quickly, the handler stops working. I get the same results placing this script in a mouseWithin handler. I remember a discussion a while ago about how often mouse events are polled at various frame rates. The problem I'm describing is much worse at 3 f/sec, and better--but still a problem--at 20 f/sec. What's the solution? Thanks! Slava [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]) Lingo-L is for learning and helping with programming Lingo. Thanks!] [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]) Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l dragging a non-moveable sprite
You're right Slava. Repeat loops suspend _all_ other animation in Director. Frame scripts won't work well either when the frame rate drops down too much. However, courtesy of timeOut objects, you can have smooth motion without the lockout of repeat loops. Here's some code over the top of my head. Untested. property pUpdateTimer property fActive on beginSprite me -- Initiate the timeOut object pUpdateTimer = timeOut(update_screen).new(100, #mUpdateScreen, me) fActive = FALSE end beginSprite me on mouseDown me -- When the user clicks, set the flag to TRUE fActive = TRUE end mouseDown me on mouseUp me -- When the user releases the cursor, set the flag to FALSE fActive = FALSE end mouseUp me on mouseUpOutside me -- When the user releases the cursor, set the flag to FALSE fActive = FALSE end mouseUpOutside me on mUpdateScreen me -- If the flag is TRUE, then update the location of the sprite if fActive then sprite(me.spriteNum).loc = the mouseLoc end if end mUpdateScreen me The idea behind using timeOut objects is that they always fire off at a fixed interval. There's no dependency on frame rate or screen refreshes. So even if you set your handler to be triggered every millisecond, it'll always work. The flag simply checks that the user has actually pressed the mouse button over the current sprite. If the flag is TRUE, then the mUpdateScreen handler updates the location of the sprite to the mouseLoc. As I said earlier, this is pretty basic code. You'll need to add the frills in it for the kind of movement you're looking for the sprite. HTH. Cordially, Pranav Negandhi New Media Applications. Learnet India Limited, Mumbai. Phone: 91-22-859 8042 Ext: 410 snip Yes, sure. Adding an updateStage after every location update makes no difference--it is still possible to break the mouse pointer away from the sprite with a quick motion, and then the hander stops working. I also tried putting the sequence in the exitFrame script. In that case, the handler always works, but is very laggy, even at 25 frames/sec. Putting the same sequence in a repeat loop, as I've seen in one DOUG article, makes the movement jerky for some reason. Also, a repeat loop suspends background actions, at least on the Mac. I don't know what else to try. snip [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]) Lingo-L is for learning and helping with programming Lingo. Thanks!]
Re: lingo-l dragging a non-moveable sprite
Well, the other suggestion with the timeOut object would be the other part which is related to the frameRate. What rate are you setting it to? What rate are you actually getting out of the performance? If it's just a small member following the mouse, you must be doing something that causes a huge performance hit? roymeo At 12:27 PM 8/20/01 -0400, you wrote: Thanks, Roy--but no, not really. The movement is still laggy, just as it was when I had the stillDown in my exitFrame handler. You're right--when I adjust location in the sprite's handlers, I lose the stillDown, but not when I do that in exitFrame: the result is the same whether I use a flag or the stillDown. The sprite moves way behind the mouse pointer (comical, almost). This is under Windows 2000, 450 MHz, D8. And the sprite's member is a small text member with Background Transparent ink. Any other ways to achieve that? At 10:43 AM 8/20/2001 -0400, you wrote: Generally the non-repeat loop way to do that is to have the mouseDown set a boolean value and you check that boolean value on the exitFrame (or more elegantly, do it in the stepFrame and add me to the actorList). You're losing the stillDown because you end up moving the mouse off the image...the smaller the image, the easier this is to do. So, on a valid mouseDown, set yourself up to continue following the mouse until you actually get a mouseUp (and mouseUpOutside) which will set the 'follow' condition to false. that help? roymeo At 10:13 AM 8/20/01 -0400, you wrote: I also tried putting the sequence in the exitFrame script. In that case, the handler always works, but is very laggy, even at 25 frames/sec. ... if the stillDown then locLeft = the mouseH - pLeftMouseOffset locTop = the mouseV - pTopMouseOffset sprite(me.spriteNum).loc = point(locLeft, locTop) end if [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]) Lingo-L is for learning and helping with programming Lingo. Thanks!] - Roy Crisman Senior Macromedia Programmer (716)724-4054 [EMAIL PROTECTED] [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]) Lingo-L is for learning and helping with programming Lingo. Thanks!]
RE: lingo-l dragging a non-moveable sprite
The sprite moves way behind the mouse pointer (comical, almost). This is under Windows 2000, 450 MHz, D8. And the sprite's member is a small text member with Background Transparent ink. Any other ways to achieve that? 80% (my gestimate) of your problem here is perception. if you turn off the mouse pointer the user won't notice the lag nearly as much! Al Hospers CamberSoft, Inc. alatcambersoftdotcom http://www.cambersoft.com Shockwave and Director development, Lingo programming, CGI scripting. A famous linguist once said: There is no language wherein a double positive can form a negative. YEAH, RIGHT [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]) Lingo-L is for learning and helping with programming Lingo. Thanks!]