Forum ‹ ActionScript 3.0 ‹ Function anonymous - errors - removeChild
7 posts
• Page 1 of 1
Function anonymous - errors - removeChild
What is the "Function Anonymous" ?
I´m getting a lot of errors when I use removeChild from AS3. And many of them display this "Function anonymous" like this:
Can´t I remove a child?
TypeError: Error #1034: Falha de coerção de tipo: não é possível converter Function em flash.display.DisplayObject.
at MethodInfo-490()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at bridge::Connection/handleMessage()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at bridge.utils::BinarySerializer/onMessage()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at MessageBuilder/AddValue()
at bridge.utils::BinarySerializer/onValue()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at TokenBuilder/AddByte()
at bridge.utils::BinarySerializer/AddByte()
at Function/<anonymous>()
I´m trying to go from one class to another (the menu screen to the game) and I´m getting the error above.
I´m getting a lot of errors when I use removeChild from AS3. And many of them display this "Function anonymous" like this:
Can´t I remove a child?
TypeError: Error #1034: Falha de coerção de tipo: não é possível converter Function em flash.display.DisplayObject.
at MethodInfo-490()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at bridge::Connection/handleMessage()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at bridge.utils::BinarySerializer/onMessage()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at MessageBuilder/AddValue()
at bridge.utils::BinarySerializer/onValue()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at TokenBuilder/AddByte()
at bridge.utils::BinarySerializer/AddByte()
at Function/<anonymous>()
I´m trying to go from one class to another (the menu screen to the game) and I´m getting the error above.
Last edited by Turrican on January 20th, 2012, 1:27 am, edited 1 time in total.
- Turrican
- Posts: 16
- Joined: August 11th, 2011, 11:50 pm
Re: Function anonymous - errors
The Player.IO error log will show you the context of the error.
The method that does error is however the result of an handleMessageHandler
/Chris
The method that does error is however the result of an handleMessageHandler
/Chris
Turrican wrote:What is the "Function Anonymous" ?
I´m getting a lot of errors and many of them display this "Function anonymous" like this:
TypeError: Error #1034: Falha de coerção de tipo: não é possível converter Function em flash.display.DisplayObject.
at MethodInfo-490()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at bridge::Connection/handleMessage()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at bridge.utils::BinarySerializer/onMessage()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at MessageBuilder/AddValue()
at bridge.utils::BinarySerializer/onValue()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at TokenBuilder/AddByte()
at bridge.utils::BinarySerializer/AddByte()
at Function/<anonymous>()
I´m trying to go from one class to another (the menu screen to the game) and I´m getting the error above.
Have more questions? Join us at #player.io on the freenode irc network. Making something cool with Player.IO? I would love to talk! My Skype handle is q-rious
-

Benjaminsen - .IO
- Posts: 808
- Joined: January 12th, 2010, 11:54 am
- Location: Denmark
Re: Function anonymous - errors - removeChild
I always get this error when I use a removeChild.
Can´t I remove a child when I use PlayerIO?
Can´t I remove a child when I use PlayerIO?
- Turrican
- Posts: 16
- Joined: August 11th, 2011, 11:50 pm
Re: Function anonymous - errors - removeChild
Turrican wrote:I always get this error when I use a removeChild.
Can´t I remove a child when I use PlayerIO?
Paste the code that errors, let's look at what you are doing.
Have more questions? Join us at #player.io on the freenode irc network. Making something cool with Player.IO? I would love to talk! My Skype handle is q-rious
-

Benjaminsen - .IO
- Posts: 808
- Joined: January 12th, 2010, 11:54 am
- Location: Denmark
Re: Function anonymous - errors - removeChild
I´ll try to explain 
I´m doing this:
Main class -> calls Menu class -> calls ChatLoby class (instantiate the lobby and chat).
When 2 players join a room, I go to the Formation Screen (another class), where the players choose the formation for their teams (it´s a soccer game):
So, when I use the parent.removeChild(this), I got this error
PS: this error happens only when I use PlayerIO. This game works ok offline (2 players at same machine), but now I´m trying to implement PlayerIO and some things (like removeChild) give this error...
Thanks!
I´m doing this:
Main class -> calls Menu class -> calls ChatLoby class (instantiate the lobby and chat).
When 2 players join a room, I go to the Formation Screen (another class), where the players choose the formation for their teams (it´s a soccer game):
- Code: Select all
if(Main.isOnline) // a variable to tell me if the game is online or offline(2 players on same machine)
{
startBt.visible=false;
startBt.removeEventListener(MouseEvent.CLICK,onStart);
startBt.removeEventListener(MouseEvent.MOUSE_OVER, overPlay);
okA.addEventListener(MouseEvent.CLICK, okAbt);
okB.addEventListener(MouseEvent.CLICK, okBbt);
Main.connection.addMessageHandler("ok1", function(m:Message, ok1:Boolean){
trace("oka");
ok0=ok1;
trace("a: " + ok0 + ok00);
if(ok0 && ok00)
{
removeListeners();
Main.gameState="jogo";
Main.formationA=formA;
Main.formationB=formB;
dispatchEvent(new Event("Init",true));
parent.removeChild(this);
}
})
So, when I use the parent.removeChild(this), I got this error
PS: this error happens only when I use PlayerIO. This game works ok offline (2 players at same machine), but now I´m trying to implement PlayerIO and some things (like removeChild) give this error...
Thanks!
- Turrican
- Posts: 16
- Joined: August 11th, 2011, 11:50 pm
Re: Function anonymous - errors - removeChild
When calling an anonymous method the this reference is lost as the scope is not preserved.
There are two easy ways to solve that, either call a private method on your class directly or use the below hack.
There are two easy ways to solve that, either call a private method on your class directly or use the below hack.
- Code: Select all
var that:Type = this;
....(function():void{
that.parent.removeChild(that)
})
Have more questions? Join us at #player.io on the freenode irc network. Making something cool with Player.IO? I would love to talk! My Skype handle is q-rious
-

Benjaminsen - .IO
- Posts: 808
- Joined: January 12th, 2010, 11:54 am
- Location: Denmark
Re: Function anonymous - errors - removeChild
Oh yeah!!!
Now I understood!!!!
This is why I´m getting some errors... thanks a lot!
SOLVED!

Now I understood!!!!
This is why I´m getting some errors... thanks a lot!
SOLVED!
- Turrican
- Posts: 16
- Joined: August 11th, 2011, 11:50 pm
7 posts
• Page 1 of 1