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

Facebook share parameter for user note from flash
Creating private packages for a group of files in a project
skin spark flash button
open swf files of different framerate with a button
Read DPI of image with ActionScript
How do i draw an square with an alpha square in the center
How do I Link and ACTIONS FRAME to a MOVIE Clip on a diffrent stage AS3?
If ActionScript is based on ECMAScript, why does it have classes and looks almost the same as Java?
Save and load a game in Adobe Air for iOS
prevent stage from receiving mouse events which occur on other objects?
Unloading an swf upon exiting frame
Adobe Flash AS3: Getting the data of selected item in a list that has a MouseEvent
embedding a font in a swf using as3
Displacement map filter does not work on masked image
Action Script 3 loading images from remote domain
Why does Milkman's StoreKit AS3 API seem to crash on second call to create()?

Categories

HOME
max
youtube-api
typo3
skypedeveloper
jquery-plugins
cryengine
where
arguments
redhawksdr
grid
ms-access-2010
psexec
autocad
rethinkdb
promotions
wkhtmltopdf
cracking
ejb-3.0
jpql
ldap-query
comma
jinja2
greensock
draw2d
legend-properties
android-navigation-drawer
procedural-generation
ithit-webdav-server
apdu
inspec
formtastic
mex
marionette
meteor-accounts
pushpad
ios9
lines
mplab
contextmenustrip
snapkit
webmock
android-geofence
stochastic-process
client-server
pygraphviz
iterm2
gem-fury
keychain
azure-web-roles
directadmin
autodesk-data-management
nshttpurlresponse
bootstrap-carousel
scrapinghub
gridgain
ocpjp
jks
visio-2010
wink
sp
node.js-client
wicketstuff
group
recursive-query
instaparse
aws-kms
jde
dynamics-nav-2013
kramdown
ios8-share-extension
maven-antrun-plugin
recode
mojolicious
taverna
vanilla-forums
properties-file
vspackage
cakephp-2.6
glog
targetprocess
vectordrawable
numerical-recipes
oxygenxml
switchpreference
dateadd
image-preloader
acrofields
facebook-java-api
logo-lang
maven-javadoc-plugin
surfaceview
cab
listpicker
usersettings
infinity.js
select2-rails
coinbase-php
magicsuggest
mmo
biztalk-deployment
idoc
orchestration
expresso-store
doxia
django-admin-tools
optimistic-concurrency
mvcmailer
stl-algorithm
apache-commons-email
zend-validate
digg
n2
javah
lgpl
mysql-pconnect
scala-designer
jettison

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile