About Al Pagan Expertise I`ll try to answer any questions you wish to throw at me, from Director 8 to MX, Mac or PC.
Experience I design generative applications in Director for use in youth groups and schools, and have also created sound and motion reactive installations for varied venues using director plugins asFFT and TrackThemColors.
Expert: Al Pagan Date: 2/28/2003 Subject: Director 8.5 Lingo Question...
Question Hi,
This might be a bit long to answer, but here we go anyway...
Hi,
I have a sprite on my stage named, "egg", and have made 4 fields, and named them 'up', 'down', 'left' and 'right'. I also have created 4 buttons with the same names. I would like the user to input numbers into the fields the click the appropriate button...the "egg" would then move according to what the user typed in...how would I overcome this?
Also, do you know where could I get more info about the history and technologies of Shockwave 3D?
Thanks in advance...
Arvind
www.djmasala.com
Answer Hi
First, to make things a little easier, make sure each of your buttons and field sprites are next to each other (eg up field = sprite(10), up button = sprite(11) etc.). Also make sure all your fields are named as you say - "up", "down" etc. It doesn't matter what the buttons are called.
Below is a script you should use as a behaviour for all your button sprites:
on mouseDown me
tempValue = value(sprite(me.spriteNum - 1).member.text)
if tempValue <> VOID then
case (sprite(me.spriteNum - 1).member.name) of:
"up": theDirection = point(0, 0 - tempValue)
"down": theDirection = point(0, tempValue)
"left": theDirection = point(0 - tempValue, 0)
"right": theDirection = point(tempValue, 0)
end case
sprite("egg").loc = sprite("egg").loc + theDirection
end
A quick explaination - the script gets the value that's been typed into the field sprite (which should be one number lower than its own button sprite: (me.spriteNum - 1)). The value is still a string (something in quotes cannot be used for mathematical caluculations, so the value at the moment could be "10"). The script converts this information into a number using the command 'value', and stores it in tempValue.
Next, the script checks tempValue to make sure that the field sprite had a number entered in the first place. If the field sprite had either a) no entry, or b) letters, then tempValue would equal VOID. If tempValue doesn't equal VOID, then the script continues.
Next, the script looks at the name of the field sprite. If the name equals "up", "down", "left" or "right", the variable theDirection is assigned a point value. point(x,y) is used as the script needs to add this information to the sprite("egg").loc to alter its position.
So, if the field "up" - sprite(15) - contains 10, and the up button - sprite(16) - is pressed, the script would convert "10" to 10, confirm it was a number, find the field name (sprite(16 - 1).member.name = "up"), create a direction - point(0, 10) - and add it to the egg sprite's location - point(320, 240) + point(0,-10) = point(320, 230).
Hope that's clear. Get back to me if you have any more problems. Good luck.