Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two-part question: Making graphics “appear”…? 1

Status
Not open for further replies.

bailey330

Technical User
Jan 25, 2003
5
SE
I would like to know if it is possible to make a graphic member (sprite) or text message “appear” and “disappear” on stage by means of:

1. A keystroke (pushing a certain letter/number on the keyboard)
2. Pushing a created button on stage (while projector is running)

Could you please explain it as if I were a complete idiot? Being new to Director, I don’t feel that far off!

Thanks!
 
Don't worry about being new, we've all been there, thats what this forum is all about. Ok, theres two ways to do this, depending on what you want. Every sprite has these two properties:

visible
blend

You can set them with a script like this:

sprite(1).visible = false
sprite(1).blend = 0

When you set a sprite's blend to 0, you cannot see it, but it can still react with other sprites (ie, collision dection). The nice thing about blend is that it's variable. If you want it to be half visible you can go:

sprite(1).blend = 50

To make your sprite reappear just set the blend to full 100

sprite(1).blend = 100

When you set a sprite's visible property to false, the sprite completely dissapears. You can't see it, it can't react to anythign, it's as if it isn't there. Another thing about visibility is it doesn't reset when you restart the movie. When you want it back you just set its visible property to true:

sprite(1).visible = true

Since visible doesn't reset itself without extra coding, i'll show you the blend method.

--Button Hide--
Create a button. Edit it's script and enter the following code:
-----
on mouseUp me

if sprite(x).blend = 100 then
sprite(x).blend = 0
else
sprite(x).blend = 100
end if

end
----
Now, x is the number of the sprite you want to hide and show. The script above togles the sprites visibilty. Here's how to have a key on the keyboard do the same thing:

--key show--
Go into the script editor. If it is on another script, click the new button (the cross thingy). If the upper bar says "behavior script", close out of the editor and get back in (it must say movie script in the top bar).

Enter this script:
--
on keyUp

if the key = ("a").charToNum then

if sprite(x).blend = 100 then
sprite(x).blend = 0
else
sprite(x).blend = 100
end if

end if

end
----

Same thing, only it happens when you hit the "a" key. Set that to any key you want. The ("a").charToNum just converts the letter in quotes to it's ascii equivalent so the handler can understand it, just in case you were wondering.

If you need any more help let me know!
 
fugigoose --

Thanks for the great help. I had success with the button method – no success with the key method.

Before I ask any other questions, I should probably explain what I am trying to accomplish…

I’m creating a corporate game “Corporate Feud” (ugh – I know) to be run “live” with a person controlling the game as it is projected on large screens. The question is displayed at the top of the screen. The answer is in four parts and stacked up top to bottom in the middle of the screen and hidden until the correct answer is given (think “Family Feud” survey board).

Since it’s highly unlikely that anyone (team) will be able to choose the “survey” answers sequentially (top to bottom), I need to be able to make any one of them appear and stay until the next correct answer is given and adds on.

Your explanation for the buttons “on/off” works great for this. In that scenario, I could line up four buttons on the bottom of the screen and click on them as the correct answers are given.

Better yet…

I could do it with keystrokes and the people in the audience would not have to see an annoying little cursor flying back and forth across the bottom of the screen.

And so now -- more questions:

I can’t seem to get the keystroke method to work. It probably has to do with me being still a bit fuzzy with where exactly to enter the script. I was able to go to “movie script,” but no luck. I’m assuming the script attaches to the sprite that will be appearing and disappearing – yes? I understand that in the button method, the script attaches to the button which in turn, controls a sprite – or in my case – the correct answer.

Here’s what I am doing (or doing wrong) to try and make the keystroke method work:

-- Right click on the sprite to be turned on/off, which is on the stage

-- Choose “script” on the popup menu

-- In the behavior script window, I hit the little italicized “i” to bring up the property inspector

-- In the property inspector I switch “type” to movie (the window title bar now says “movie” as you stated)…

-- I paste in this script – exactly as shown:

on keyUp

if the key = ("a").charToNum then

if sprite(x).blend = 100 then
sprite(x).blend = 0
else
sprite(x).blend = 100
end if

end if

end

-- I fill in the (x) with my sprite number (which is 3 in this case). The code now looks exactly like this:

on keyUp

if the key = ("a").charToNum then

if sprite(3).blend = 100 then
sprite(3).blend = 0
else
sprite(3).blend = 100
end if

end if

end

-- I close the property inspector, bring the stage to the front and hit play

-- I press “A” on the keyboard….nothin’ happens!

Where am I going wrong?

And further – I will have four or five questions -- all with four part answers, so 16 to 20 answers in all. Is the keystroke method best for this? When I switch to the next question and the corresponding “survey” answers, do I have to use all new keys for those? Or…can I use the same keys for each set of “survey” answers – say 1 thru 4 at the top of the keyboard?

“And the survey says…”!

Again thanks for all of the great information. Your help has been very appreciated!

Sorry for the long winded post…



 
Opps – one other thing I forgot…

How does one change a push-button’s color? My button appears as white and I want it to be dark gray…

Thanks again!
 
One more question :) – when I create a projector, the text (questions/answers, created within director) looks horrible – how can I correct this? It seems as if some “render at low quality” setting is switched on. The graphics look fine in the projector – again, it’s just the text that looks jagged and bad.

Strange because -- the text looks great within director…

Humm….

Thanks again so much – the assistance is really invaluable as I make my way over this learning curve…
 
Never mind about the last two posts – I figured out the button color and crappy looking text issue(s). Everything looks great now.

Still though -- the “keystroke” method is a bit perplexing…

Since I answered two of my own questions above, I figure I must have a credit :)– so here goes another question…

The push button on/off function is working great. The problem is this:

I want to have the button (and controlled sprite) be in the “off” state initially – then appear when the button is clicked. At present, the button resets automatically upon playing the movie to the “on” position with the sprite already on stage. Not good. I don’t want him to appear until I say so!

I’ve made several attempts to ‘reverse’ the script, but no luck. Really, I’m just taking stabs in the dark and hoping to get lucky…

Thanks again for all of the help…
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top