Journal:2008october25 researching flash game: Difference between revisions
m (→Try This: add carriage return) |
m (→Try This: actually, I don't think we need this.) |
||
Line 46: | Line 46: | ||
onClipEvent (unload) { | onClipEvent (unload) { | ||
function checkhit(){ | function checkhit(){ | ||
if( | if(was_hit) | ||
{ | { | ||
_root.success._visible = true; | _root.success._visible = true; |
Latest revision as of 20:29, 24 October 2008
The task
Make a Flash game that will detect if the user misses targets.
the problem
It's easy to detect if targets (buttons) are hit, but how do we know if they are *not* hit?
sub problem
Though I have two computers, I don't have the power supply for the one with Flash 8 installed.
sub solution
So I'm going to write these notes for what I think will work, but no guarantees. Once I've got my power supply for my white MacBook, I'll try to follow these notes.
therefore
Hopefully this page will become a tutorial that people can use to solve the main problem
First Post
I figure this problem should be pretty common, so I posted a message on Kirupa, asking how to detect if a button is not pressed. Two and a half days later (and counting), no answer.
First Research
Okay, I still figure this problem is common, so I searched on actionscript game tutorial, looked at the top hit: http://www.developal.com/tutorials/tutorials262.html, which gave me a broken link on their top hit, and then found Building Games in Flash 5 - Part 3 - Enemies and collisions by David Doull.
On page 3 of this, I found some code:
onClipEvent (load) { function reset(){ this._x=600; this._y=random(200)+100; enemySpeed=random(4)+1; } reset(); }
which was suggested to be put in the movie clip's actionscript.
Oh! So if we can do an onClipEvent (load), I bet there are other onClipEvents. Top hit gives me http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary614.html, which shows that we can also do onClipEvent (unload).
Try This
onClipEvent (unload) { function checkhit(){ if(was_hit) { _root.success._visible = true; } else { _root.failure._visible = true; } } checkhit(); }