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 07-08-2011, 06:51 PM   #1
debsied
Member
 
Join Date: May 2011
Posts: 74
Default [AS2] Incrementing Correct Hits to Navigate Drag and Drop

Sorry - should have said - AS2

I'm sorry to post again on the same subject but the reply I got didn't help me and I am stuck.

I am trying to track the number of correct hits to navigate forward from a drag and drop game but it doesn't work.

I was told that it's because I need to increment the value of hitsNum after every stop drag but I thought I was doing that with hitsNum++;. The hits count up and display in the text but the gotoAndPlay doesn't work.

I am a beginner so please, if you are kind enough to reply, can you spell out for me what I need to do?

Thanks so much for your time.

fla file attached

Code:
var hits: Number = 0;
var hitsNum:Number = 1;

function updateHits(){
	hitsTxt.text = hits;

//commented out things I have tried to get the increment to work
mc.onRelease = function(){
	if (this.hitTest(target_mc))
		//hits += hitsNum;
		hits++;
		updateHits();
		mc._x = targetmc._x;
                mc._y = targetmc._y;
		//hits = hits + 1;
stopDrag();
		//hitsNum += 1;
                //hitsNum++;

//Various things I've tried for the gotoandPlay

        if (hitsNum==5) {
		
		this._parent.gotoAndPlay("end_page");
	}
	if (hits==5) {
		
		gotoAndPlay("end_page");
	}
	
	if (hits>=5) {
		
		this._parent.gotoAndPlay("end_page");
	}
Attached Files
File Type: zip Score_routing_CS3.zip (251.0 KB, 71 views)

Last edited by debsied; 07-08-2011 at 07:00 PM.
debsied is offline   Reply With Quote
Old 07-12-2011, 01:41 AM   #2
tacos
Grrrrrrrrreat!
 
tacos's Avatar
 
Join Date: Apr 2007
Location: Montréal, Québec
Posts: 5,473
Default

In your present script hitsNum never increases, hits does.
So check for hits not hitsNum in an onEnterFrame function (you want it to continuously check the hits number, not just only once with a single if statement...), added at the end of your script...

ActionScript Code:
this.onEnterFrame = function(){     if (hits>=5) {         gotoAndStop("end_page");         delete this.onEnterFrame;     } };
__________________
WHO I WAS...
BANDS OF THE 80's
tacos is offline   Reply With Quote
Old 07-12-2011, 05:36 AM   #3
debsied
Member
 
Join Date: May 2011
Posts: 74
Default

Aaaaaaah!!!! So simple when you know how!!

I can't tell you how much I appreciate your help. I am trying to learn from books and tutorials but nothing has helped me as much as the help I have had from this forum.

Thank you SO SO much!!!!

Deborah
debsied is offline   Reply With Quote
Old 07-12-2011, 01:25 PM   #4
tacos
Grrrrrrrrreat!
 
tacos's Avatar
 
Join Date: Apr 2007
Location: Montréal, Québec
Posts: 5,473
Default

Grrrrrrrrrrrreat!
__________________
WHO I WAS...
BANDS OF THE 80's
tacos 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 12:49 AM.

///
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.