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

Random flashing white pixel at the bottom of the insertion point/caret in TextField? (Flash/AS3)
Actionscript regex false negative
air app crash when load some pict
How add UNDO to my text field in AS3?
as3 pepperFlash check on runtime
Actionscript 3 will not work with movie clips
Presets with actionscript 3.0
Dynamically creating DataGrid from imported .txt file
Server Side Compilation for .mp4 and .swf
Unable to get actionscript to load xml file then loop
AS3 How i can get anchor point (pivot, registration point) position from Display Object
\n as3 pasting to Clipboard
Flex 4.6 compiler check if compiling for ios or android
Randomly occurring Error #1010 in already existing movie clips
Function not triggering when called in ActionScript3
AS3 - Reset Loader's Animation

Categories

HOME
skype-for-business
azure-active-directory
teradata
netty
ide
download
jshell
multipartform-data
pdf-generation
sitemap
olap
activejdbc
kairosdb
dynamics-crm-2011
camunda
exchange-transport-agents
loader
email-client
procedural-generation
ps
android-wear-2.0
kundera
spring-data-gemfire
semantic-ui-react
2checkout
blockly
n1ql
gitosis
incapsula
intersection
stdin
nscollectionview
linkurious
azure-web-roles
mixed-models
colorbox
geminabox
hdpi
openxava
runtime-permissions
visualizer
fluent-nhibernate-mapping
htop
nservicebus6
android-vectordrawable
petapoco
was
ios-keyboard-extension
scrollmagic
robotc
scanf
esprima
huawei
sqlproj
blackberry-webworks
glade
init
syslog4j
avi
transaction-isolation
database-administration
user-profile
phpdesigner
sqlxml
periodic-processing
markerspiderfier
magnet-uri
windows-kernel
webservices-client
play-json
updating
adempiere
first-order-logic
sparkcore
p4python
tidesdk
copy-on-write
data-quality-services
redmine-plugins
ios-enterprise
dotcmis
disabled-control
amzi-prolog
isl
xtify
grape-api
playing-cards
select2-rails
coinbase-php
magicsuggest
nsregularexpression
configurationsection
certificate-revocation
nude.js
eeprom
xpolog
response-time
mass-emails
calendarextender
mdd
manuals
user-preferences

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