This content has been marked as final. Show 6 replies
I would use an on keyDown function instead of an exitFrame function. You
probably want that dvIncrement variable to be a property rather than a
global variable, unless you're using its value somewhere else in the
You say that you are looking for clicks on arrows at the bottom of the
stage. Are these arrows sprites? The code that you are using is looking
for key presses on the arrow keys on the computer keyboard. If you want
to use sprites then the code will be completely different.
Adobe Community Expert
On Wed, 26 Apr 2006 09:17:12 GMT, merc_maniac posted in
In addition to Rob's observations:
> Here is the code I am using, but there seems to be a problem with it.
Care to share what you mean by that? We're not looking over your shoulders
from out here
> case true
I can't test right now, but I suspect that should be:
case true of
Mark A. Boyd
Sorry, I have just started using director recently, so this is all a little new to me. Yes the arrows are sprites, which explains then why the code I am using is not working!
Does the keypressed 123 refer to the left button on a keyboard, or can it be used in my case allowing the user to press down on a left arrow sprite on stage, which will in turn make the sprite object (a ball) move left?
Sorry if this seems like a really stupid question.
No, you will have to use new and different code to control one sprite
from another. I can't really tell you what you need to do as I don't
know what it is that you want to accomplish or what other code you may
You might want to go through the tutorials and the example files that
come with Director. They may help to explain how Director works.
Adobe Community Expert
The way I would do this.
Attach a behavior to the ball with two handlers
On BeginSprite me
theBallsSpriteNum = spriteNum
on MoveBall me, WhichDirection
myIncrementAmount = 2
case whichDirection of
"up":sprite(spriteNum).locV = sprite(spriteNum).locV - myIncrementAmount
"down":sprite(spriteNum).locV = sprite(spriteNum).locV +
"left":sprite(spriteNum).locH = sprite(spriteNum).locH -
"right":sprite(spriteNum).locH = sprite(spriteNum).locH +
Name the arrow cast members up, down,left, right respectively and attach a
behavior with this handler
on mouseUp me
sendSprite(theBallsSpriteNum, #MoveBall, sprite(SpriteNum).member.name)
A couple of comments.
I use an older version of Director. I believe newer versions allow you to
name sprite channels, in which case there is no need to save the balls
sprite number in a global variable the way I did it here.
I use the name of the arrow sprites, so that I can attach the same behavior
to each one. This tells the MoveBall handler which direction to move the
I have the newer version of Director, so i'll give that a go now.