Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Closed Thread
 
Thread Tools Rate Thread Display Modes
Old 07-17-2012, 05:48 PM   #1
yogidishman
Registered User
 
Join Date: Jun 2009
Posts: 39
Default #2025 error

I am using Flash CS4 AS3
I have two buttons that when clicked either add or remove the five items listed below onto my stage. The code for the add button works fine and adds the objects to the stage each time I press it. The remove button works fine the first time removing the objects without generating an error but after the first time I if I add the objects back onto the stage using the addon button and then press the addoff button I get the #2025 error indicated below.

I found some code on the internet that allows me to trace and display the parent of these objects on "stage" but even when I use the stage.removeChild() command Flash is still generating the error each subsequent time that I use my remove button. Can someone please tell me why this is happening and how to fix it. Note that the .swf works regardless of this error but the error is annoying and should be fixable. Thank you.

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at MethodInfo-112() error

//I am using these commands to define and add the five objects on stage.


var wheels:MovieClip = new totalwheel
var wheelflap:MovieClip = new flap
var wheelflap2:MovieClip = new flap2
var flapholder:MovieClip = new holder
var handy:MovieClip = new hand

addon_btn.addEventListener(MouseEvent.CLICK, placeonStage);
function placeonStage(e:MouseEvent):void
{
stage.addChild(wheels)
wheels.x=400
wheels.y=350
stage.addChild(flapholder)
flapholder.x=400
flapholder.y=-30
stage.addChild(wheelflap)
wheelflap.x=400
wheelflap.y=30
stage.addChild(wheelflap2)
wheelflap2.x=400
wheelflap2.y=30
stage.addChild(handy)
handy.x=700
handy.y=300
{

//These are the commands I use to remove the above objects from the stage.
These work fine the first time around but generate the above error when used subsequent times

addoff_btn.addEventListener(MouseEvent.CLICK, removeThem);
function removeThem(e:MouseEvent):void
{
stage.removeChild(wheels)
stage.removeChild(flapholder)
stage.removeChild(wheelflap)
stage.removeChild(wheelflap2)
stage.removeChild(handy)
}
yogidishman is offline  
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:36 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.