Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > General > Gaming and Game Development

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-27-2012, 04:45 PM   #1
Rockyeaster07
Registered User
 
Join Date: Apr 2012
Posts: 5
Default [AS2] Problem with flash game

Hi there, I'm creating a Spot the difference flash game, new to flash, i have 7 differences and i need to know how to make it so, when all 7 differences are clicked and have the circle it can go to the You win screen?
Rockyeaster07 is offline   Reply With Quote
Old 04-27-2012, 04:53 PM   #2
Prid
Prid - Outing
 
Prid's Avatar
 
Join Date: Oct 2009
Location: Halden, Norway
Posts: 1,191
Send a message via MSN to Prid Send a message via Skype™ to Prid
Default

Declare a variable in your Frame:

score = 0;

and then for each right difference found, in the button code for the difference, in the on(release) or on(press) (or even onRelease/onPress) part of the code, include an if statement, and increment the score variable:

ActionScript Code:
score++; if(score == 7){     _root.gotoAndStop("win_screen"); }

Tutorials to Read:
If Conditional
__________________
I have returned, and am now 18
Prid is offline   Reply With Quote
Old 04-29-2012, 05:03 AM   #3
Rockyeaster07
Registered User
 
Join Date: Apr 2012
Posts: 5
Default

Sorry to be a total noob, but really unsure on this.. any other way to explain it for a noob?
Rockyeaster07 is offline   Reply With Quote
Old 04-29-2012, 05:18 AM   #4
xdeath
Deaths touch!!!
 
xdeath's Avatar
 
Join Date: Mar 2008
Posts: 775
Default

Quote:
Originally Posted by Rockyeaster07 View Post
Sorry to be a total noob, but really unsure on this.. any other way to explain it for a noob?
how he explained it was pretty basic. but i'll take a shot at explaining it.

ok so its a spot the difference game right? well lets say everything that is considered a "difference" will be a movieclip or a button placed on the stage.
so you have 7 differences, 1 movieclip/button for each difference. that makes 7 total.

following me so far? now what Prid was trying to tell you was there two ways of doing this. you can click on each movieclip/button and place the code on there or you can simply do it all on the main timeline. depending on how you choose to do it depends on how you write the code for its pressed.

see if you click the button/movieclip and press F9 to enter code then you'll have to use this for when its pressed:
ActionScript Code:
on(press){ // do something }

if your doing it all on the main timeline and not on the buttons directly. then you'll do it like this:
ActionScript Code:
/* when you place the movieclip/button on the stage click it and give it an instance name. assuming you had called one of them difference1. then this is how you'd write it: */ difference1.onPress = function(){ // do something }

now looking at Prids post you should understand it much better. so lets look at it. he want you to your frame (meaning on the main timeline) and place that variable there.

then on the movieclips/button if you put the code in a press event like i did above you can enter his code in there and it will work like a charm. so did that clear things up for you?

Last edited by xdeath; 04-29-2012 at 05:26 AM.
xdeath is offline   Reply With Quote
Old 04-29-2012, 12:04 PM   #5
Rockyeaster07
Registered User
 
Join Date: Apr 2012
Posts: 5
Default

Code:
on(release)
{
this.gotoAndStop(2);
_root.spots_Left --;

}
I have the variable set up on the frame, ^ that is the code for my button atm which is working fine, but not sure how to add the code prid has given? Sorry to be a complete noob, i started flash like 1 week ago. Cheers.
Rockyeaster07 is offline   Reply With Quote
Old 04-29-2012, 12:56 PM   #6
xdeath
Deaths touch!!!
 
xdeath's Avatar
 
Join Date: Mar 2008
Posts: 775
Default

not that its relevant but if you just started learning flash why on earth learn as2? as3 is better in pretty much every way.

as for prid's code it should look like this:
ActionScript Code:
on(press){     _root.score++;     if(_root.score == 7){         _root.gotoAndStop("win_screen");     } }

i normally use as3. but that should work.
xdeath is offline   Reply With Quote
Old 04-29-2012, 04:15 PM   #7
Rockyeaster07
Registered User
 
Join Date: Apr 2012
Posts: 5
Default

This is what i have set up.

Dynamic Text - gyazo.com/cd1d2312dbd3316cc0e8ac17941538eb
Frame - gyazo.com/286e83461edf58d33c847cb1ef340bc3
Button - gyazo.com/f9af9104c0458561c604fe01695ae5c8

I have no compile errors, but it just doesn't work, when the button is clicked the red circle i have for the difference shows up, but the dynamic text doesn't go down if you get what im getting at... Anyone know why?
Rockyeaster07 is offline   Reply With Quote
Old 04-29-2012, 06:29 PM   #8
Rockyeaster07
Registered User
 
Join Date: Apr 2012
Posts: 5
Default

Anyone?
Rockyeaster07 is offline   Reply With Quote
Old 04-30-2012, 12:01 PM   #9
PasD
pseudoActionscripter
 
Join Date: Apr 2012
Posts: 68
Default

Quote:
Originally Posted by xdeath View Post
not that its relevant but if you just started learning flash why on earth learn as2? as3 is better in pretty much every way.

as for prid's code it should look like this:
ActionScript Code:
on(press){     _root.score++;     if(_root.score == 7){         _root.gotoAndStop("win_screen");     } }

i normally use as3. but that should work.
hes a total noob. Its easier for noobs to learn as2 than as3. As2 is perfectly suited for creating noob games like spot the difference. As3 is too verbose, its more for applications and complex games.
PasD is offline   Reply With Quote
Old 04-30-2012, 12:03 PM   #10
PasD
pseudoActionscripter
 
Join Date: Apr 2012
Posts: 68
Default

Quote:
Originally Posted by Rockyeaster07 View Post
Anyone?
why when your score is == 0 you gotoAndStop(3). what is frame 3?
PasD is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:45 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.