Be a Supporter!

on_click... anywhere? help! (AS2)

  • 263 Views
  • 13 Replies
New Topic Respond to this Topic
Aeroth
Aeroth
  • Member since: Dec. 14, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
on_click... anywhere? help! (AS2) 2009-10-03 12:24:15 Reply

okay I'm in actionscript 2, and I have drawn a gun that I have under this actionscript (where the gun is "cursor")-

stop();
Mouse.hide();
startDrag("_root.cursor",true);

inside the movie clip I have a stop action on the timeline, then after that the gun firing.

What I want to know, is what code can I use so that when I click, it plays the gun firing? I have a feeling its something along the lines of -

onClick - anywhere
play movie.cursor;

only it isn't that. Can anyone help?

flailthefox
flailthefox
  • Member since: Aug. 30, 2007
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to on_click... anywhere? help! (AS2) 2009-10-03 12:33:59 Reply

HMMMMM

let me think.
First, in your movieclip, have 1 frame with stop on for it not firing, and the next frame have a movieclip inside with with the gun firing, but have the stop on the main movieclip. EG) 3 movieclips, one called MC, one called MCgun1, and MCgun2 (MCgun2 is the one firing).
Perhaps, if you have the cursor for the gun on screen and then having something like this in the movielcip:

on(press) {
this.gotoandstop(2);
}

then it will go to frame two on your main movieclip, use the firing animation, and stop.
NOW, DONT COPY/PASTE, underatand it, or else your not learning anything.


Destroyed.

7IsUnlucky
7IsUnlucky
  • Member since: Jun. 12, 2007
  • Offline.
Forum Stats
Member
Level 26
Blank Slate
Response to on_click... anywhere? help! (AS2) 2009-10-03 12:35:09 Reply

Look at some of these.


420 blaze it faggot

Aeroth
Aeroth
  • Member since: Dec. 14, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to on_click... anywhere? help! (AS2) 2009-10-03 13:44:40 Reply

At 10/3/09 12:33 PM, flailthefox wrote: HMMMMM

let me think.
First, in your movieclip, have 1 frame with stop on for it not firing, and the next frame have a movieclip inside with with the gun firing, but have the stop on the main movieclip. EG) 3 movieclips, one called MC, one called MCgun1, and MCgun2 (MCgun2 is the one firing).
Perhaps, if you have the cursor for the gun on screen and then having something like this in the movielcip:

on(press) {
this.gotoandstop(2);
}

then it will go to frame two on your main movieclip, use the firing animation, and stop.
NOW, DONT COPY/PASTE, underatand it, or else your not learning anything.

I understand it, but that actionscript is for a button, and i don't want it to fire when i click a BUTTON, just when i CLICK (anywhere in general). Thanks for the help and the learning motivation, but I haven't got any further.

At 10/3/09 12:35 PM, 7IsUnlucky wrote: Look at some of these.

wow. Great that really helped. And thanks for the amazing effort to actually help me. NOT. I don't want to surf through hours of tutorials I have already seen only to find just ONE piece of actionscript I could just get if someone who perhaps already knew it could nudge me in the right direction.

Could anyone else help?

Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to on_click... anywhere? help! (AS2) 2009-10-03 14:11:25 Reply

learn frame coding:

function onMouseDown () {
//code
}

bad habbit coding:

onClipEvent(mouseDown) {
//code
}


AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature
DanBomer
DanBomer
  • Member since: Apr. 1, 2006
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to on_click... anywhere? help! (AS2) 2009-10-03 15:20:08 Reply

At 10/3/09 02:11 PM, Yambanshee wrote: learn frame coding:

function onMouseDown () {
//code
}

Learn frame coding:

onMouseDown = function () {
//code
}

BBS Signature
Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to on_click... anywhere? help! (AS2) 2009-10-03 15:24:23 Reply

At 10/3/09 03:20 PM, DanBomer wrote:
At 10/3/09 02:11 PM, Yambanshee wrote: learn frame coding:

function onMouseDown () {
//code
}
Learn frame coding:

onMouseDown = function () {
//code
}

Ive heard that my method is more efficient


AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature
Wolfos
Wolfos
  • Member since: Jan. 19, 2008
  • Offline.
Forum Stats
Member
Level 25
Game Developer
Response to on_click... anywhere? help! (AS2) 2009-10-03 15:36:53 Reply

use onMouseDown or something like that, you don't even need buttons

Aeroth
Aeroth
  • Member since: Dec. 14, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to on_click... anywhere? help! (AS2) 2009-10-03 15:43:15 Reply

At 10/3/09 03:24 PM, Yambanshee wrote:
At 10/3/09 03:20 PM, DanBomer wrote:
At 10/3/09 02:11 PM, Yambanshee wrote: learn frame coding:

function onMouseDown () {
//code
}
Learn frame coding:

onMouseDown = function () {
//code
}
Ive heard that my method is more efficient

Thanks, I've tried using that code, and i got this

onMouseDown = this.gotoandstop(2); {
//code
}

But i got a compiler error saying "Statement must appear within on/onClipEvent handler
can someone please correct this!?

Aeroth
Aeroth
  • Member since: Dec. 14, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to on_click... anywhere? help! (AS2) 2009-10-03 16:14:27 Reply

Okay. I know have this -

on(onMouseDown) {
this.gotoandplay(2);
}

No compiler errors this time :), the downside however is that it doesn't do anything.

Just to recap, I want it so when you click the mouse; the timeline in the movie clip plays.

7IsUnlucky
7IsUnlucky
  • Member since: Jun. 12, 2007
  • Offline.
Forum Stats
Member
Level 26
Blank Slate
Response to on_click... anywhere? help! (AS2) 2009-10-03 18:38:46 Reply

At 10/3/09 04:14 PM, Aeroth wrote: Okay. I know have this -

on(onMouseDown) {
this.gotoandplay(2);
}

No compiler errors this time :), the downside however is that it doesn't do anything.

Just to recap, I want it so when you click the mouse; the timeline in the movie clip plays.

Why the fuck would you put 2 ons?
You really should learn more about actionscript before trying to do anything.
Just make a big-ass box with 0 alpha and make it a button. Have it so when it's clicked on, whatever shit you want to happen happens,


420 blaze it faggot

7IsUnlucky
7IsUnlucky
  • Member since: Jun. 12, 2007
  • Offline.
Forum Stats
Member
Level 26
Blank Slate
Response to on_click... anywhere? help! (AS2) 2009-10-03 18:41:14 Reply

Or, god damnit, why did you replace "function" with "gotoAndStop"? Do you even know what you're doing?
In a frame, put this:

onMouseDown = function () {
_root. MC NAME HERE.gotoAndStop(2);
}

420 blaze it faggot

Aeroth
Aeroth
  • Member since: Dec. 14, 2008
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to on_click... anywhere? help! (AS2) 2009-10-03 20:23:40 Reply

At 10/3/09 06:41 PM, 7IsUnlucky wrote: Or, god damnit, why did you replace "function" with "gotoAndStop"? Do you even know what you're doing?
In a frame, put this:

onMouseDown = function () {
_root. MC NAME HERE.gotoAndStop(2);
}

Oh I'm sorry if i gave the impression that I knew what I was doing by asking what to do.

Anyway, i'm not angry at you, I am happy. Thankies. It worked. (except i changed the Stop to a Play, that way it played the whole movie clip)

7IsUnlucky
7IsUnlucky
  • Member since: Jun. 12, 2007
  • Offline.
Forum Stats
Member
Level 26
Blank Slate
Response to on_click... anywhere? help! (AS2) 2009-10-03 21:28:40 Reply

Good.


420 blaze it faggot