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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use 2 events for same action? 1

Status
Not open for further replies.

markdmac

MIS
Dec 20, 2003
12,340
US
Brand new to Flash and I am following the tutorial for creating a Flash movie game found here:

I've successfully modified the sample FLA file and replaced my own graphics into the file. The game plays great.

I would like to add new functionality to the game and allow the user to use the spacebar in addition to the left mouse click to activate the trigger. Problem is I have barely started to figure out the Flash interface let alone the scripting language it uses. I'm a pro at VBScript but this is new to me. Can anyone offer suggestions?

Thanks.
 
Thanks Kenneth!

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
OK, so that does work but not in the way I want it to. Using the following code for the button that acts as a trigger:

Code:
on (press) {
	gotoAndPlay(2);
	_root.score++;
}
on (keyPress "<Space>"){
   gotoAndPlay(2);
	_root.score++;
}

I can use the mouse and it works flawlessly recording both hits and misses. Using the spacebar it does not matter if the player aims or not, the space bar always causes the target to be hit. Ideally I would like for the spacebar to evaluate the x,y coordinates of the mouse and then call the button press. Is that possible?
 
I tried too apply my general scripting knowledge (if only I could use vbscript for this) and tried this:

Code:
on (press) {
    gotoAndPlay(2);
    _root.score++;
}
on (keyPress "<Space>"){
   (press);
}

But that did nothing. Is there a way to have the space bar call the button press action?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Works like a charm. Thank you I have learned a lot from this little piece.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top