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

Actionscript 3.0 Error opening URL error
Setting the value of a PopUpMenuButton programmatically?
AS3: How to check, all zip files has been extracted?
Action Script3 error #1176
Getting the error, “The application cannot be installed due to a certificate…”
AS3 copy and paste with colour formatting
adt error - “… is not part of a Mac OS X Native Extensions framework”
How to make a public method that is not inherited by subclasses?
Change the size of text if charcters > at 15
Actionscript3 Loader error (ERROR #2044, #2032)
Subdivide lines(made by points array) by equal length
Action script 3 walking animation
How can I fix the wrong timing of my fade/scroll animation?
Change variable type in runtime AS3
How to access object's parent's propertie, from his event function?
migrating Flex Air application to Web application error not able to import flash.data

Categories

HOME
excel-formula
google-cloud-pubsub
stanford-nlp
ide
weblogic
intellisense
assign
aggregation-framework
autocad
clip-path
runtime
resharper
oxid
tmux
logstash-configuration
exchange-transport-agents
facebook-marketing-api
smooth-scrolling
web-parts
android-actionbar
audio-streaming
hl7-fhir
ajaxcontroltoolkit
continuous-fourier
gulp-jshint
spock
ds-5
jbossfuse
paper-trail-gem
ios9
lines
wordpress-rest-api
jql
imdb
unity3d-5
favorites
rtos
pyenv
realloc
form-fields
libconfig
gem-fury
quartz
vpython
taleo
xmldom
evaluation
standard-error
gige-sdk
senti-wordnet
try-catch-finally
totalview
wicketstuff
lattice
directinput
cedar-bdd
boost-range
shtml
treelist
paypal-subscriptions
firefox-os
containstable
google-app-engine-php
dynamics-nav
overlapping
controlpanel
wiql
angular-promise
ruby-1.8.7
database-project
vanilla-forums
joomla3.3
xml-simple
dcg
genome
radgrid
veeam
conkeror
quickfixn
formbuilder
nsnotificationcenter
data-layers
nvcc
logo-lang
sygic
oc4j
usersettings
cocotron
bho
gwt2
ntdll
jquery-ui-map
wxperl
capitalization
recess
backlight
qvariant
datarelation
google-local-search
database-agnostic
versions
mysql-pconnect
morfik
coderush-xpress
stackless

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App