Play the games, create the levels

Topic, Please help! (Flash AS2)

Checkout our iPhone & iPad games!

You must register or log in to post a message.

geckojsc 15 years ago
  Oh good! I'm not so stupid after all.
I got to go to bed now though, even though I get th day off school tomorrow. It's midnight here...
Captain_404 15 years ago
  If it's in the root then yes, if it's inside another movie clip its parent is that movieclip.

So, yes, I think.
geckojsc 15 years ago
  If it was on a movieclip placed the stage, would the parent be _root? I don't know much about that area of actionscript.

For now I'm not actually working on ASCIIsnake, and I don't know if I will for a long time...
Captain_404 15 years ago
  You can, but you have to adjust their depth first, otherwise it won't work. (at least, that's how it goes down in mx04)

just use a

/*your mc name*/.swapDepth(/*parent of your mc*/.getNextHighestDepth());

right before you use the removeMovieClip();
Hexicube 15 years ago
  Yes, you can...which is how mine should have worked, but failed instead!
geckojsc 15 years ago
  Oh, that's quite good. I didn't realise you could use removeMovieClip for movieclips that you had not created in run-time.
Hexicube 15 years ago
  How about:

onEnterFrame=function()
{
if(score>=target)
play()
}

And the hittest (on the movieclip):

if(name1.hitTest(name2))
{
++_root.score
this.removeMovieClip //after ++_root.score
}
Treazer 15 years ago
  @gecko
When create you "ASCIIsnake"?
Or you dont create because you already created a game called "Path 4 Mouse"?
Shiro 15 years ago
  That's one happy man...
Vlykarye 15 years ago
  i can help!!!
Omg! i can help!
mail me :D
geckojsc 15 years ago
  When using code inside a movieclip, make sure anything you link to that is on the main scene (such as variables and other movieclips) has "_root." before it.

So for example:
score = 15;

becomes...

_root.score = 15;

Maybe you knew that already, and maybe that's not the problem.
Hexicube 15 years ago
  It seems that it doesn't work inside movieclips...
Hexicube 15 years ago
  i always wondered how to make a constant checker...thanks!
[edit] @jp: i think that is what play does, must be another peice of code on another frame...
geckojsc 15 years ago
  Thanks Captain_404! That worked perfectly!

Here's the .fla file.

Before you ask, I didn't program the snake myself, but I plan to program everything else myself. Thanks for your help guys!
THeNiNJa 15 years ago
  I would like to see the rest of your code aswell..
jp 15 years ago
  gecko, where in your code do you change the value of the "score" variable ?
Captain_404 15 years ago
  Yes, that is correct. If you want your code to check constantly you'll need to put it inside an onEnterFrame function.

Like so:

onEnterFrame = function() {
//do stuff
}
geckojsc 15 years ago
  Thank for your help, but it still doesn't quite work. Even though the score now starts at 0, when I get some food, the game still wont play...

Here's my code now:
SPOILER


I also tried it with a ; as well.

Maybe it's because the code only checks once, and it should be constantly checking somehow.
Captain_404 15 years ago
  I don't think it does, as far as I know this is programming syntax universal to most languages.

I'm stuck using mx04 (about F7) until I get some decent cash flow though, so really I have no clue if it works for f8+
THeNiNJa 15 years ago
  Doesn't that depend on your version of flash, Captain?
That code would work in flash 8. It's a nice habit to use == and ;'s though.
Captain_404 15 years ago
  should be

if (score == target) {

one = tells flash to make one value equal to another
two ='s tells flash to check if one variable is already equal to another
geckojsc 15 years ago
  So, I'm making a game called ASCIIsnake, and I have two variables, one called score and the other called target. Here is the code I'm having problems with:

SPOILER


When the snake eats some food, the score goes up by one.
This code makes the score go to one anyway, and it doesn't play. Can anybody help?


[1]

Flash game development

First post of the topic

geckojsc 15 years ago
  So, I'm making a game called ASCIIsnake, and I have two variables, one called score and the other called target. Here is the code I'm having problems with:

SPOILER


When the snake eats some food, the score goes up by one.
This code makes the score go to one anyway, and it doesn't play. Can anybody help?

Our free flash games   Games for your site   Games for your iPhone   Contact   Twitter @jpsarda & @bonuslevelorg