actionscript-3


Why can't I remove this Movieclip?


I have a TouchEvent function onTouch inside the constructor function of a item_Potion class that gets run when a Movieclip is touched. This function goes through a series of unrelated checks and then in the end it is supposed to remove itself (the Movieclip).
At the end of the onTouch function it is supposed to remove itself by doing the following:this.parent.removeChild(this);
However, this does not work.
I get the following error message:
TypeError: Error #1010: A term is undefined and has no properties.
at Function/item_Potion/$construct/onTouch()[E:\Clients\org\tcdsb\ZenithsReach\item_Potion.as:56]
at runtime::ContentPlayer/simulationSendTouchEvent()
at runtime::SimulatedContentPlayer/clientSocketDataHandler()
The line it's reffering to for the error message (Line 56) has the following:
this.parent.removeChild(this);
My imports:
` import flash.display.Stage;
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.*;
import flash.events.TouchEvent;
import flash.net.dns.AAAARecord;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;`
I know the problem is not with the other portions of my code because I have tried switching this line out with visible = false; and I get no errors. Therefore, I am certain that the issue is with the way I am removing the MovieClip, and that is where I need help.
Similiar Sources I have tried that do not work:
How to make a MovieClip remove itself in AS3?
parent is undefined in your example, hence the error "a term is undefined...".
You can avoid the error by wrapping your code in:
if (parent) {
parent.removeChild(this);
}
But based on your comment providing [object global] is sounds like you might actually want something like:
event.currentTarget.parent.removeChild(event.currentTarget);
Which would remove the object that the touch event listener was added to.

Related Links

ShowAllDataTips only in a LineSeries
Not able to type in input textboxes in AC3 when attempt the scene in the second time
AS3: Caching files without user interaction?
Choice for multi-platform application development
How to get specific item from Array Collection in Adobe Flex 4.6
How can we broadcast live video from SWF running in flash player to Azure Media Services Live Streaming? [closed]
Move Components in the Title Bar?
AS3 efficient way to make a disabled state
call a function when component visibility changes
Actionscript3 Simple platform collision confusion
JWplayer. Change destination source with http request
Switching images after a mouse hover in a Flash banner
How to add keyboard interaction in AS3
Improve function speed that uses remainder:
How to deobfuscate AS3 source code?
Variable scope in function closure?

Categories

HOME
gulp
azure-documentdb
botframework
stanford-nlp
sip
customization
reference
lithium
sms
docker-compose
open-search-server
annyang
dcos
dynamics-crm-2011
dompdf
owncloud
template10
filehelpers
android-actionbar
geography
novacode-docx
restructuredtext
pumping-lemma
apdu
datastax-enterprise
aws-certificate-manager
my.cnf
cloudformation
federated
r-factor
language-detection
restler
aweber
motherboard
redhat-brms
mybatis-generator
lfe
ssdp
mtm
apiman
reqif
npoco
activeandroid
runner
openidm
jcifs
aot
typewriter
hellosign
cardview
sqlproj
copy-constructor
easy-thumbnails
indoor-positioning-system
require-handlebars
diameter-protocol
innertext
jcalendar
cexception
askbot
controlpanel
producer-consumer
updating
roslyn-code-analysis
copy-on-write
veeam
teamstudio-unplugged
fiware-health
api-eveonline
yosemite
zoneminder
azure-worker-roles
dotcmis
episerver-7
lettuce
opencobol
iwork
class-library
.net-reflector
code-complete
google-mirror-api
google-voice
mobile-robots
azure-pack
wpa
msbuild-task
cloudmade
nx
phone-state-listener
jquery-1.8
django-admin-tools
idtabs
yii-cactiverecord
method-call
iphone-maps
pkcs#7
cross-cutting-concerns
asp.net-1.1

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile