Clock Crew

Community => General Discussion => Topic farted by: RocketFetus on January 31, 2009, 08:19:26 PM

Title: Need a little help in AS
Post by: RocketFetus on January 31, 2009, 08:19:26 PM
I'm trying to add a thing where a counter will go up every time an action is performed and also go back one frame

Specifically I want it to say THING (#)

I already have the if statement set up. I just need actionscript within the if statement that:

1. Makes the counter do the THING (#) starting with one and keep going up (don't know if there is supposed to be  a limit but if there is, 100 preferably.

2. takes the movie back one frame!

i'm a noob i know.

edit:

Thank you guys for the help. I'm having a little trouble though, the counter doesnt work. :\

I've tried naming the counter thing "counter" and named it's instance "counter" and then I put the actionscript as    counter++;

but it doesnt work... are there any additional settings?
Title: Need a little help in AS
Post by: The Spoiler on January 31, 2009, 08:25:51 PM
I'm not sure what you mean for the THING part, but to go to the previous frame use prevFrame();
For obvious reasons use it after the other part.
For the THING part, do you want it to do a trace command or change something in a text box?

Edit: You said counter. I'm a dumbass.

If you want to have a counter in a text box/field, on the text field under 'Properties' or something theirs a text box that says 'Var' (If you make a dynamic text, which you should). Type in a variable name there then declare that variable somewhere in the code (On the first frame or something). Then in the if block (but before prevFrame) put
var++;
with var replaced with the variable's name. If you want to keep the variable from going beyond a certain limit put the var++ within an if block like so

if ( var>100){
var++;
}

Edit again: If you want some text next to the number make sure they're in different text fields. Make the text one static and the number one dynamic like I said above. You could have them in one field if you really wanted, but that would take more work.
Title: Need a little help in AS
Post by: RocketFetus on January 31, 2009, 08:28:20 PM
Yes it is possible even if it goes back one frame? The counter?
Title: Need a little help in AS
Post by: Bigglesnoots on January 31, 2009, 08:29:14 PM
I'm not sure what you mean by "actions" but I take it that it's just buttons being clicked.

Include this on all buttons that would mean "preforming an action"

on(press){
     countervariablegoeshere++;
     framevariablegoeshere--;
     nameofthemovieclip.gotoAndStop(framevariablegoeshere);
}
_root works too instead of a movieclip, if you want the whole movie to go back one frame.

edit: ye prevframe works too, I just like using vars.
Title: Need a little help in AS
Post by: RocketFetus on January 31, 2009, 10:43:19 PM
Thank you guys for the help. I'm having a little trouble though, the counter doesnt work. :\

I've tried naming the counter thing "counter" and named it's instance "counter" and then I put the actionscript as    counter++;

but it doesnt work... are there any additional settings?
Title: Need a little help in AS
Post by: RocketFetus on January 31, 2009, 11:05:27 PM
Quote from: Franklin G. Hamilton;1511726for dynamic textboxes you put var as counter, not the instance name.

then you can reference it like _root.counter = 343425453;


Resolved!

Thanks!!

edit: THANKS GUYS IT'S MY FIRST TIME MAKING A GAME