61 Forum Posts by "moynzy"
At 4/30/14 01:53 AM, GeoKureli wrote:At 4/30/14 01:43 AM, moynzy wrote: I'm sorry to be a pain, but what time is best to call the scrollworld function, when the players moves?yes, when the player moves.
You are a genius! Smartest guy I know to date!
Your knowledge in logic and programming has helped me so much!
If there is anything I can do, please ask!
I'm in debt to you!
Thank you a million!
At 4/30/14 01:22 AM, GeoKureli wrote: small typo in the code earlier.
var globalPos:Point = new Point(character.x, character.y);
globalPos = ground.bottom.localToGlobal(globalPos);
while(ground.bottom.hitTestPoint (globalPos.x, globalPos.y, true))
{
globalPos.y -= .1; //<--- Fixed typo
hero.incrementUp();
}
hero.keepOnGround();
You are genius!
I just made alterations to the code though if that's fine
private function groundCollision():void
{
var globalPos:Point = new Point(character.x, character.y);
globalPos = ground.bottom.localToGlobal(globalPos);
var onGround:Boolean = false;
while(ground.bottom.hitTestPoint (globalPos.x, globalPos.y, true))
{
globalPos.y -= 0.1; //<--- Fixed typo
character.incrementUp();
onGround = true;
}
if (onGround)
{
character.keepOnGround();
}
}
This fixes the problem! Thank you!
container.x = -character.x + stage.stageWidth / 2;
container.y = -character.y + stage.stageHeight/ 2;
this is making the container go up and down now, due to the incrementing and decreasing.
I'm sorry to be a pain, but what will the best time to call the scrollworld function be when the players moves?
Thanks again!
At 4/30/14 01:02 AM, GeoKureli wrote: First off, and this won't help you're problem but I have to say it
don't do this
if (ground.bottom.hitTestPoint (globalPos.x, globalPos.y, true))
{
while(ground.bottom.hitTestPoint (globalPos.x, globalPos.y, true))
{
the if() is completely useless. The while() is all you need
Secondly,
if (ground.bottom.hitTestPoint (globalPos.x, globalPos.y, true))
{
}
else{
character.keepOnGround();
}
What is the reasoning for the if? you need to start using the '!' operator.
if ( !false) trace("to negatives make a positive");
But this just gives me a terrible errorPost the contents of the hero's incrementUp() function. the error might be there.
Another issue might be that your using localToGlobal wrong. if ground is not positioned at 0,0 then it can mess things up. if ground has it's own position you'll have to do.
while(ground.bottom.hitTestPoint (globalPos.x+ground.x, globalPos.y + ground.y, true))
But it seems more likely that the issue is in hero.incrementUp().
Sorry, I've been following tutorials and i've seen this technique.
Here is the increment code
public function incrementUp():void
{
this.y -= 0.1;
//trace("incrementing");
}
public function keepOnGround():void
{
//trace("onGroundBitch");
//grav = 0;
yV = 0;
//trace(yV +"on")
//trace(grav);
positionOnLand();
}
public function positionOnLand():void
{
//overide
//class that extends this just traces "landed";
}
At 4/30/14 12:39 AM, GeoKureli wrote:At 4/29/14 02:18 PM, moynzy wrote: The end result is this.Are you saying hat everything is fine now and it's working, or is there still an issue? I can't tell.
refer to last please
No no, I have an error with hitTest now.
hitTestPoint code fails when ground and container are placed in sprite.
I've tried DisplayObject's localToGlobal function.
But this just gives me a terrible error
var globalPos:Point = new Point(character.x, character.y);
globalPos = ground.bottom.localToGlobal(globalPos);
if (ground.bottom.hitTestPoint (globalPos.x, globalPos.y, true))
{
while(ground.bottom.hitTestPoint (globalPos.x, globalPos.y, true))
{
character.incrementUp();
if (ground.bottom.hitTestPoint (globalPos.x, globalPos.y, true))
{
}
else{
character.keepOnGround();
}
}
}
the error is
[Fault] exception, information=Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
I don't know what else to do now.
At 4/29/14 09:57 AM, 666666a wrote: Well, I mean what I need for programming!
Hello,
What you need is Flash Develop.
It's a very good tool!
Another tool is Flash Adobe, and if you like you can use them both to create visually beautiful games!
You also need spare time, will power, and the feeling that you actually want to learn!
(Another thing that helps is a bottle of whiskey, and tissues, to dry off the tears).
At 4/29/14 05:55 AM, Muja wrote: Hello, I'm new to AS3 (I've always worked on AS2 until now).
What I'm trying to do is to build a in-game "medals system", in which the user can see not just the medals he earned but also how many gamers were able to win each medal.
Keeping in mind that this game will be posted on Newgrounds, is this even possible script-wise?
I've been looking all over for a tutorial - problem is, I don't really know what I'm looking for...
Hello, I save my game using the shared object library.
It stores a cookie in the players hardrive (temp) and then I check if the shared object is -- to a variable.
If it is then player has medal, if not then player doesn't.
At 4/28/14 09:30 AM, milchreis wrote: And if the movement is relative (move by 5 pixels) and once the player is positioned,
you only have to move the container in the opposite direction, without the need to specify the absolute position it should have on screen.
milChreis! I did it, kinda!
The red thing is the container
//add everything to the container
container.addChild(ground);
ground.x = 700;
ground.y = 680;
addChild(timerGIF);//this does not need to scroll
groundCheckPoint = ground.x;
container.addChild(character);
character.x = 640;
character.y = 300;
After doing so I process collision
if (ground.bottom.hitTestPoint(character.x +13, character.y, true || ground.hitTestPoint(character.x -13, character.y, true)))
{
while(ground.bottom.hitTestPoint(character.x +13, character.y, true || ground.hitTestPoint(character.x -13, character.y, true)))
{
character.incrementUp();
if(ground.bottom.hitTestPoint(character.x +13, character.y, true || ground.hitTestPoint(character.x -13, character.y, true)))
{
}
else
{
character.keepOnGround();
}
}
}
Then after that I scroll the world! /container
container.x = -character.x + stage.stageWidth / 2;
container.y = -character.y + stage.stageHeight / 2;
The end result is this.
refer to last please
At 4/28/14 07:05 AM, evowolfdemon wrote: Here is a link to my flash game <a>http://www.newgrounds.com/dump/item/b1d3d9a55aa8ed3c57588def7601559a
This game was made for some children that have Gastroesophageal reflux disease and the point is to teach them what foods to eat and I was wondering what some people thought of this game.
I love the character design.
I would work on the interface and the graphics.
Make the movements smoother, and the amount of food that falls less(you can increase the amount as the player develops).
Remember, kids/children have poor motoring skills (not all).
The speed was too fast for me and I could not tell which food was hitting me so It was confusing for me.
Overall, great work! You're on track!
P.s - comic sans font will be your friend,
At 4/27/14 07:48 PM, milchreis wrote: You are asking for something you already had:
http://www.newgrounds.com/bbs/topic/1364517
Are you a troll?
mil, i'm being serious, I've tried putting everything in to a container(world which is datatype to Sprite).
I'm sorry if my posts are annoying, i'm slowly learning but I'm trying to find an explanation,
Please understand.
At 4/27/14 01:37 PM, GeoKureli wrote: are you still scrolling your world by moving each object individually?
Yes I am Geo,
As I said ground is a movieclip with the level in,
the enemy is not added to the ground
nor is the hero.
I don't know how to add them to a sprite, and if i do, then how do I change my code to suit the sprite?
if everything is in a sprite it will mean
if(sprite.hero.hits(sprite.floor)
{ do this}
As a human being, i am begging you to help me please.
private var world:Sprite = new sprite();
world.addChild(hero)
world.addChild(level)
world.addChild(enemy)
Liek this?
Hey guys, got an issues with tween max.
When I hit an enemy I use tween max to move the enemy, but my scrolling of the world makes tween max go glitchy.
Is there a way I can make my enemy move then stop?:
Listen to the people above, trust me!!
If you need transparency export as png-24
if you don't need transparency jPEG
cVams are good for animations
But buggy for games.
BEST OF LUCK!
At 4/24/14 03:40 PM, stickman8190 wrote: I having a problem with something, I'm making a birdseye view game with a player being able to shoot bullets, i'm trying to make it so when bullet hitTestObject enemy, it removes the bullet
this is the coding for the enemy spawning:
function createEnemy(event:TimerEvent):void{
var enemy:MovieClip = new enemy_mc();
enemy.x = enemySpawn.x;
enemy.y = enemySpawn.y;
addChild(enemy);
enemy.addEventListener(Event.ENTER_FRAME, enemySettings);
function enemySettings(event:Event):void{
if(contains(enemy)){
enemy.x = enemy.x+((player_mc.x-enemy.x)/enemySpd)
enemy.y = enemy.y+((player_mc.y-enemy.y)/enemySpd)
var cy:Number = player_mc.y - enemy.y;
var cx:Number = player_mc.x - enemy.x;
var Radians2:Number = Math.atan2(cy,cx);
var Degrees2:Number = Radians2 * 180 / Math.PI;
enemy.rotation = Degrees2;
}
}
}
and this is the bullet coding
function MouseisDown(event:MouseEvent):void{
if(shooter){
var bullet_mc:MovieClip = new Bullet();
a = a + 1;
b = b - 1;
bullet_mc.x = player_mc.x
bullet_mc.y = player_mc.y
bullet_mc.rotation = player_mc.rotation + Math.random() * 25 - 10;
shootTimer.start();
addChild(bullet_mc);
bullet_mc.addEventListener(Event.ENTER_FRAME, removeBullet);
function removeBullet(event:Event):void{
if(contains(bullet_mc)){
if(bullet_mc.hitTestObject(wall_mc)){
removeChild(bullet_mc);
}
if(bullet_mc.hitTestObject(enemy)){
removeChild(bullet_mc);
}
}
}
}
if(noAmmo){
snd2.play();
}
}
The bold coding near the end is the problem, it kept saying
Scene 1, Layer 'AS3', Frame 1, Line 193 1120: Access of undefined property enemy.
is there another way to do it?
Are you removing the event lisetners?
Make a class for your bullet
Inside that class
bullet
addeventlistener,onADD
onADD function
remove event listner
initialite
addeventlistner.enterFrame
Enterframe function
if(clicked and char is looking up)
this,y go up
else
if(clciked and char is looking down
this.y go down
Remove bullet function
parent.removemovieclip
removeeventlistner
//In your main.
If(mouseclick)
addChildBulletToPlayer
push that bullet in to an array!
Loop through the array
for i = 0 ; i < aBulletArray.lengh; i++
var currentBullet = new Bullet(this is the class name) = aBulletArray,lengh[i] ( the i in the bracket means the one i nthe loop
if currentBUllet < stage width then currentBullet.RemoveBullet(the function we made)
//if the currentbullet goes, we call this func to remove the event listner and bullet
then we want to remove the bulletfro narray
abulletarray,splice[i] (We remove the current bullet, hence i, we target this one)
That's my solution
It's crappy pesduo code,
Hopefully you can, or someone can extend this.
Hey guys, it's me again.
I'm trying to make my player climb a ladder.
if(player hits ladder)
can climb = true;
if(upkey)
if (canClimb)
//character.y - = climbspeed (which is 3)
else
character,jump(Jumps);
when the player jumps
yV = jumpheight;
When the player is on the ground..
yV = 0;
So can anyone maybe, help me climb to success or point me in the right "climbing" direction. Sorry.
thank you.
It's got to do with the velocity right?
Much love !
MOD. Please delete. Wrong forum.
At 4/23/14 07:21 PM, egg82 wrote:At 4/23/14 06:55 PM, moynzy wrote: grav = 0.6;assume y = 0
//y velocity
yV = 0;
private function fall(e:Event):void
{
yV += grav;
this.y += yV
}
frame 1: y = 0.6
frame 2: y = 1.2
frame 3: y = 1.8
frame 4: y = 2.4
etc...
grav - = jumpHeight (lets say jump height is -5)0.6 -(-5) = 5.6
this means grav will be -18 and there fore vY will be adding - 18 on to its self which meansMaths, they don't quite do what you think they do.
Unless we're missing some essential bit of code.
My Maths is terrible :O!
<pre>
public class OnGround extends MovieClip
{
public var grav:Number;
public var friction:Number;
public var xV:Number;
public var yV:Number;
protected var charIsrunning:Boolean;
protected var isDefending:Boolean;
protected var isJumping:Boolean;
public function OnGround()
{
addEventListener(Event.ADDED_TO_STAGE, init)
charIsrunning = false;
isDefending = false;
//gotoAndStsop("jump");
}
private function init(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
//gravity
grav = 0.6;
//y velocity
yV = 0;
//x velocity
xV = 0
friction = 0.9;
addEventListener(Event.ENTER_FRAME, fall);
}
private function fall(e:Event):void
{
yV += grav;
this.y += yV
}
public function incrementUp():void
{
//this.y -= 0.1;
//trace("incrementing");
}
public function keepOnGround():void
{
//trace("onGroundBitch");
var nought:Number = 0;
grav = nought;
yV = 0;
trace(yV +"on")
trace(grav);
positionOnLand();
}
public function positionOnLand():void
{
//overide
}
</pre>
<pre>
if (ground.level1Ground.hitTestPoint(getChildAt(c).x + 13, getChildAt(c).y, true) || ground.level1Ground.hitTestPoint(getChildAt(c).x - 13, getChildAt(c).y, true))
{
getChildAt(c).y --;
//OnGround(getChildAt(c)).incrementUp();
OnGround(getChildAt(c)).keepOnGround();
touchingGround = true;
}
else
{
//OnGround(getChildAt(c)).falll();
touchingGround = false;
}
</pre>
Char control keys
<pre>
public function moveLeft():void
{
//decrease VELOCITY
xV -= 2;
this.gotoAndStop("run");
//add this to the Mc . x pos baby.
this.x += xV;
this.scaleX = -1;
charIsrunning = true;
}
public function moveRight():void
{
//increase VELOCITY
xV += 2;
this.gotoAndStop("run");
//add this to the Mc . x pos baby.
this.x += xV;
this.scaleX = 1;
charIsrunning = true;
}
public function dontMove():void
{
//if no button presses then do this
this.gotoAndStop("stop");
//slowd down ball
xV *= friction;
charIsrunning = false;
isDefending = false;
//stop the ball if you're not moving
if (xV > - 1 && xV < 1)
{
xV = 0;
}
}
override public function positionOnLand():void
{
isJumping = false;
///=gotoAndStop(1);
}
public function defend():void
{
isDefending = true;
this.gotoAndStop("defend");
charIsrunning = false;
}
public function attack():void
{
this.gotoAndStop("attack");
}
public function jumpUp():void
{
//jumpheight--;
if (!isJumping)
{
//jumpheight--;
grav = -0.6;
//this.y -= 60;
this.gotoAndStop("jump");
isJumping = true;
//
}
}
</pre>
That'a what I've tried and implemented but my char gets stuck in mid air :/ cause grav is not pulling him down.
guys I'm making a game and I've changed my gravity code to this.
//ehehe
private function init(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
//gravity
grav = 0.6;
//y velocity
yV = 0;
//x velocity
xV = 0
friction = 0.9;
addEventListener(Event.ENTER_FRAME, fall);
}
private function fall(e:Event):void
{
yV += grav;
this.y += yV
}
Question is, that I can't turn back gravity on or am I doing it wrong.
//hehe
if the player hits the platform
{
//turn grav to 0?
//or yV to 0?
touchingGround
and do I increment players.y position -- so it looks like it's standing accuratelty
}
Another question about jumping.
If I want to jump, how do i jump
//heehe
if(player is touching ground)
if the upKey is pressed
grav - = jumpHeight (lets say jump height is -5)
this means grav will be -18 and there fore vY will be adding - 18 on to its self which means
the players y pos will be shooting up wards.
How to make the player come back?
Cheers guys :D
Much love !
The Game (Don't play as Coraline, she's Alpha)
So, it's me, the guy who can't side scroll :P
Problem is that the when I hit the green box, the player should not go through it, and then down again.
It does that, BUT! It has that nudge which is annoying and it makes the stage go "CRAZY SHAKEY BABEY"
Sorry.
So, how can I fix this.
When the player jumps it jumps -18; (y pos)
When the players y pos has gone -18 then gravity kicks in and brings it down till it hits the ground.
//code hehe
if (ground.downHit.hitTestPoint(getChildAt(c).x, getChildAt(c).y - getChildAt(c).height, true))
{
//trace("fall downOnGround(getChildAt(c)).grav;");
//trace(OnGround(getChildAt(c)).grav);
character.y += 15;
}
//thehe
public function jumpUp():void
{
if (!isJumping)
{
isJumping = true;
this.gotoAndStop("jump");
grav = -18;
}
}
P.s this is a none tile based platformer.
Any tips or directions would be very much appreciated to me.
Thank you.
At 4/20/14 08:18 AM, MetalBooster wrote: I am making a platformer game in which the player is equipped with a chainsaw.I want that when he uses it and it strikes a wall or enemy,sparks are seen just beside the chainsaw.What code should I use?
var sparks:Sparks = new Sparks
addChild(char)
addChild(spark)
spark.x = char.x (then position it ur self
e
if(player hits wall or enemy)
spark visible is true
else if no hit
it's false
??
At 4/17/14 10:25 PM, GeoKureli wrote:At 4/17/14 10:14 PM, moynzy wrote:^^^^^^ are you ever defining the property 'ground'?Access of possibly undefined property ground
changing any other part of the code won't fix that
is ground a movieclip on the .fla stage with an instance name 'stage'?
ground is a movieclip, it has the linage name Ground.
private var ground:ground;
ground = new Ground();
Shouild i declare the layer var first?
Sorry, I go off and try different and stupid things :L you will learn to dislike me more perhaps, and one day even enough to hate me to due to my stupidity :L
What I'm going to do is actually listen to someone's piece of advice!
I've also tried changing
childrenOnStage = this.numChildren;
to
childrenOnStage = _scrollLayer.numChildren;
Still no luck.
At 4/17/14 09:32 PM, GeoKureli wrote:At 4/17/14 09:30 PM, GeoKureli wrote: put everything you want to scroll into a new Sprite().this goes for the hero too; remember, the hero is scrolling just like everything else, it just looks like it's not.
//
_scrollLayer.addChild(character);
//character.reset();
//character.x = 640;
character.y = 0;
//level
_scrollLayer.addChild(ground);
ground.x = 640;
ground.y = 680;
//greenGoblin
_scrollLayer.addChild(goblin1);
goblin1.x = 500;
goblin1.y = 0;
_scrollLayer.addChild(goblin2);
goblin2.x = 800;
goblin2.y = 0;
_scrollLayer.addChild(goblin3);
goblin3.x = 100;
goblin3.y = 0;
//red Goblin
_scrollLayer.addChild(redGoblin1);
redGoblin1.x = 1100;
redGoblin1.y = 400;
//redGoblin1.reset();
So i've created a sprite above the main constructor
_scrollLayer:Sprite = new Sprite();
Then as you can see they have been added to the sprite!!
But this then messes up my coding structure, because...
//
for (var c:int = 0; c < childrenOnStage; c++)
{
if (getChildAt(c).name == "player")
{
if (ground.hitTestPoint(getChildAt(c).x, getChildAt(c).y, true))
{
touchingGround = true;
while (ground.hitTestPoint(getChildAt(c).x, getChildAt(c).y, true))
{
OnGround(getChildAt(c)).incrementUp();
if (ground.hitTestPoint(getChildAt(c).x, getChildAt(c).y, true))
{
}
else
{
OnGround(getChildAt(c)).keepOnGround();
}
}
}
this doesn't crash, it just doesn't work , 'cause ground has been added to _scrollLayer.
I have tried
_scrollLayer.ground... but I get an error
1119: Access of possibly undefined property ground through a reference with static type flash.display:Sprite.
P.s - thanks for not giving up on me yet :d
At 4/17/14 09:30 PM, GeoKureli wrote: this is the 3rd scrolling thread you've started, and you haven't listened to me before. don't move everything else to make it look like the player is moving the other way. put everything you want to scroll into a new Sprite(). call it scrollLayer or something. when you want to move the camera right, move the scroll layer left. or just set the position of the container based on the position of the hero.
_scrollLayer.x = -_hero.x + stage.stageWidth / 2;
_scrollLayer.y = -_hero.y + stage.stageHeight / 2;
Sorry, I go off and try different and stupid things :L you will learn to dislike me more perhaps, and one day even enough to hate me to due to my stupidity :L
What I'm going to do is actually listen to someone's piece of advice!
Oh, did you put "<" code ">"? "<"/code">"
Trace the index when you get to the spawn point?
//
private function scrollStage():void
{
if (lastPosX != lastPosX)
{
canScrollStage = false;
}
else
if (lastPosX == lastPosX)
{
canScrollStage = true;
}
if (canScrollStage)
{
if (rightKey)
{
//move background left
//something.x +=(stage.stageWidth * 0.5) - character.x * 2;
}
else
if (leftKey)
{
//move backgrounf Roight
}
for (var b:int = 0; b < childrenOnStage; b++)
{
if (getChildAt(b).name == "enemy")
{
getChildAt(b).x +=(stage.stageWidth * 0.5) - character.x
}
}
ground.x += (stage.stageWidth * 0.5) - character.x
}
else
{
//move the background
}
// do this last, everything moves around object
character.x = stage.stageWidth * 0.5;
lastPosX = character.x;
}
The problem is that everything moves around the player.
But when I reset the player....
//
private function playerFalls():void
{
if (character.y > stage.stageHeight)
{
//take life away and go back to check point or back to reset
character.x = stage.stageWidth * 0.5;
character.y = 20;
//goblin1.reset();
//goblin2.reset();
//goblin3.reset();
//stage.x = stage.stageWidth * 0.5;
//canScrollStage = false;
}
}
if i use
//
//character.x = stage.stageWidth * 0.5;
Then my character ends up in the middle, but it will end up in the middle since the scroll function dictates the player to be in the centre always.
I have tried
//
character.x = (stage.stageWidth * 0.5) - 400;// moves him back
but if character falls off left of the screen then he is moved back.
Any one have a solution for this please?
Hi, I am trying to make clip_Square1 spawn clip_Triangle on top of clip_Square1 when clicked, and then move it around with clicks on the scene until it collides with clip_Square2 and gets removed.
The Problem right now is that instead of spawning on top of Square1 (coordinates 115,243) it spawns it the top left corner and then moves there.
Can you help me fix this?
Thanks in advance.
Please use the "" tags it will help members read your code, thus help you greater.
If you want to get the one object on top of another ,change the index of that object in the displayobject. That's all I can help.
At 4/17/14 02:30 PM, milchreis wrote: The code that removes your objects is a lot more complex than the code that adds them.
Why don't you simply take this code:
addChild(character);
character.x = stage.stageWidth * 0.5;
character.y = 0;
addChild(ground);
ground.x = 640;
ground.y = 680;
lastPosX = character.x;
addChild(goblin1)
goblin1.x = 500;
addChild(goblin2)
goblin2.x = 800;
addChild(goblin3)
goblin3.x = 100;
and remove the children the way you added them?
This code has nothing to do with any event listeners, for loops, numchildren or whatever.
Keep it simple. Then, when that works, you can try and improve the code, make it more versatile, etc.
I game the goblins a name enemy, loops through the children on stage, if the children has the name, then remove them. Removal proccess.
I got it, i'm silly when it comes to small things
addChild(goblin1)
goblin1.x = 500;
goblin1.y = 0;
addChild(goblin2)
goblin2.x = 800;
goblin2.y = 0;
addChild(goblin3)
goblin3.x = 100;
goblin3.y = 0;
I traced their y axis, they were still falling. Random for y should be 0, but yeah, all done thanks :)
Thanks :D
At 4/17/14 02:09 PM, milchreis wrote:At 4/17/14 02:06 PM, moynzy wrote: OR what does it come in hand for?It comes in handy when you want to know when the DisplayObject is removed from the display list.
That's pretty much it.
If you don't have a use for it, don't worry.
mil Chreis, since you've replied, can you help me with a problem?
addChild(character);
character.x = stage.stageWidth * 0.5;
character.y = 0;
addChild(ground);
ground.x = 640;
ground.y = 680;
lastPosX = character.x;
addChild(goblin1)
goblin1.x = 500;
addChild(goblin2)
goblin2.x = 800;
addChild(goblin3)
goblin3.x = 100;
I add all of the 3 enemies, player and ground here.
Then when the player goes back, I remove everything
private function fromLevtoStart(e:MouseEvent):void
{
if (e.target == backBtn1)
{
stage.removeEventListener(Event.ENTER_FRAME, level1)
stage.addEventListener(Event.ENTER_FRAME, mainGameLoop)
//container.removeChild(_character);
removeChild(character);
removeChild(ground);
childrenOnStage = this.numChildren;
for (var b:int = 0; b < childrenOnStage; b++)
{
if (getChildAt(b) is Goblin)
{
removeChild(getChildAt(b));
b--;
childrenOnStage = this.numChildren;
}
}
this.gotoAndStop(2);
}
}
}
I remove these.
but when I go back to press the game again,
the player is added, ground is added and the enemies are not
I traced (numChildren) before and after and they both were 10.
Which means my goblins have been added, but where?
Hey guys,
I've use addEventListner(Added To stage)
and this helps me initialize the classes variables when it's added to stage.
However, what can I do with remove from stage listener?
Set the variables back to default?
OR what does it come in hand for?
My suggestion will help you with multiple toilet brushes
Loop through your toliet brush (or brushes)
and if you find that toliet brush then move it, if not then don't do anything :)

