Solved

Problem with classes

Posted on 2012-03-28
7
212 Views
Last Modified: 2012-04-28
Hi there,

I'm nearing the end of my Web Imaging and Animations course for the semester.  Tweening and masking seemed pretty easy but as soon as we started Actionscript I started having some trouble.

Our latest lab involves creating a basic Flash game.  Balloons fall and the user has to click the balloons to pop them.  I had the balloons falling after I downloaded an example .FLA for falling snow.  It used a document class though.  The problem is that I need the game to run when on the second frame, not when the .FLA is compiled as a whole.

You can see the balloon part when you compile the current version of it.  I need this to happen only after the 'start' button is clicked.

Any considerations would be much appreciated

Here's a link to the project files :

Project Files
0
Comment
Question by:duder78
7 Comments
 
LVL 39

Accepted Solution

by:
blue-genie earned 250 total points
ID: 37780561
first of all when you compile your file, you'll see you get compile time errors.

Definition com:Balloon could not be found.

You seem to have confused your document Class - with the balloon.
if you specify Balloon as your document class - that is what will happen - as soon as the file loads - your balloon will be instantiated.

What i would recommend you do, instead of combining timeline code with an AS code - create a Main class - use that as the "Controller" for your game - set it as your Document class. Include the start btn code etc in there.
0
 

Author Comment

by:duder78
ID: 37785118
Allright,  I scrapped what I had and started over.  I definitely think that I've made progress but I've hit a snag again.  In the third frame I loop through the children in an attempt to clear the stage (signifying the end of the game) but only a few of the bubble disappear leaving 4 or 5 still drifting towards the bottom.  

I thought that this block of code should work but it doesn't :

for(var i = 0; i < numChildren; i++)
{
	if(i > 2)
	{
		if(getChildAt(i) != null)
		{
			removeChildAt(i);
		}
	}
}

Open in new window


Knowing that getChildAt(0). (1) and (2) are the buttons and score text field, I want to leave them alone hence the if(i > 2) .

So, my main problem is removing all the bubbles from the stage in frame 3.  I also can't get the score to update properly if anyone wants to take a look but it's not a big deal.

Thanks for any considerations

Here's the most recent version of the bubbles project :

Bubbles TAKE TWO
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 37785932
ok will have a look at it and revert - might have to wait till the weekend if someone doesn't have a go before then.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:duder78
ID: 37789709
No rush blue genie!  Thanks..
0
 
LVL 29

Assisted Solution

by:dgofman
dgofman earned 250 total points
ID: 37791263
You have to remove "com" from your import. You didin't define a package name in Ballon.as class

import Balloon;

var balloon:Balloon = new Balloon();
addChild(balloon);
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 37905390
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now