Skip to main content
Participant
May 15, 2012
Question

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.

  • May 15, 2012
  • 3 replies
  • 6053 views

hello, im working in develop a flash website.. and i have this problem in ending the video each time click other button. i show u my code..

var currentButton = "home";

var home1 = 1;

var dc1 = 0;

var char1 = 0;

var movie1 = 0;

Object(this).content1.all_content_content.visible = 100;

Object(this).content1.comic_content.visible = 0;

Object(this).content1.character_content.visible = 0;

Object(this).content1.movie_content.visible = 0;

Object(this).content1.all_content_content.gotoAndPlay(2);

//button all ---------------------------------------------------------------------------------;

Object(this).content1.all_button.home_btn.addEventListener(MouseEvent.MOUSE_DOWN, home);

function home( event:MouseEvent):void

{

          if (home1 == 0)

          {

                    Object(this).content1.all_content_content.visible = 100;

                    Object(this).content1.all_content_content.gotoAndPlay(11);

                    Object(this).content1.comic_content.visible = 0;

                    Object(this).content1.character_content.visible = 0;

                    Object(this).content1.movie_content.visible = 0;

                    currentButton = "home";

                    home1=1

                    dc1=0

                    char1=0

                    movie1=0

                    endAll();

 

          }

 

}

Object(this).content1.all_button.dc_btn.addEventListener(MouseEvent.MOUSE_DOWN, dc);

function dc( event:MouseEvent):void

{

          if (dc1 == 0)

          {

                    Object(this).content1.all_content_content.visible = 100;

                    Object(this).content1.all_content_content.gotoAndPlay(11);

                    Object(this).content1.home_content.visible = 0;

                    Object(this).content1.character_content.visible = 0;

                    Object(this).content1.movie_content.visible = 0;

                    currentButton = "dc";

                    home1=0

                    dc1=1

                    char1=0

                    movie1=0

                    endAll();

 

          }

 

}

Object(this).content1.all_button.char_btn.addEventListener(MouseEvent.MOUSE_DOWN, character);

function character( event:MouseEvent):void

{

          if (char1 == 0)

          {

                    Object(this).content1.all_content_content.visible = 100;

                    Object(this).content1.all_content_content.gotoAndPlay(11);

                    Object(this).content1.comic_content.visible = 0;

                    Object(this).content1.home_content.visible = 0;

                    Object(this).content1.movie_content.visible = 0;

                    currentButton = "char";

                    home1=0

                    dc1=0

                    char1=1

                    movie1=0

                    endAll();

 

 

          }

 

 

}

Object(this).content1.all_button.movie_btn.addEventListener(MouseEvent.MOUSE_DOWN, movie);

function movie( event:MouseEvent):void

{

          if (movie1 == 0)

          {

                    Object(this).content1.all_content_content.gotoAndPlay(11);

                    Object(this).content1.comic_content.visible = 0;

                    Object(this).content1.home_content.visible = 0;

                    Object(this).content1.character_content.visible = 0;

                    Object(this).content1.movie_content.visible = 0;

                    currentButton = "movie";

                    home1=0

                    dc1=0

                    char1=0

                    movie1=1

          }

 

}

//button all ---------------------------------------------------------------------------------

//

Object(this).content1.all_content_content.addEventListener(Event.ENTER_FRAME,myContent);

function myContent(event:Event)

{

          if (currentButton == "movie")

          {

                    if (Object(this).content1.all_content_content.currentFrame == 1)

                    {

                              Object(this).content1.all_content_content.visible = 0;

                              Object(this).content1.movie_content.visible = 100;

                    }

                    else

                    {

                              Object(this).content1.all_content_content.play();

                    }

          }

          else

          {

                    if (Object(this).content1.all_content_content.currentFrame == 10)

                    {

                              Object(this).content1.all_content_content.gotoAndStop(10);

                              if (currentButton == "dc")

                              {

                                        Object(this).content1.comic_content.visible = 100;

                              }

                              if (currentButton == "home")

                              {

                                        Object(this).content1.home_content.visible = 100;

                              }

                              if (currentButton == "char")

                              {

                                        Object(this).content1.character_content.visible = 100;

                              }

                    }

                    else

                    {

                              Object(this).content1.all_content_content.play();

                    }

          }

}

//;

//;

var scrollDirection = "no";

Object(this).content1.comic_content.btn_comic_left.addEventListener(MouseEvent.MOUSE_OVER, leftMove);

function leftMove( event:MouseEvent):void

{

          scrollDirection = "left";

}

Object(this).content1.comic_content.btn_comic_left.addEventListener(MouseEvent.MOUSE_OUT, leftMoveNo);

function leftMoveNo( event:MouseEvent):void

{

          scrollDirection = "no";

}

Object(this).content1.comic_content.btn_comic_right.addEventListener(MouseEvent.MOUSE_OVER, rightMove);

function rightMove( event:MouseEvent):void

{

          scrollDirection = "right";

}

Object(this).content1.comic_content.btn_comic_right.addEventListener(MouseEvent.MOUSE_OUT, rightMoveNo);

function rightMoveNo( event:MouseEvent):void

{

          scrollDirection = "no";

}

Object(this).content1.comic_content.addEventListener(Event.ENTER_FRAME,myhomeContent);

function myhomeContent(event:Event)

{

          if (scrollDirection == "left")

          {

                    Object(this).content1.comic_content.comic.x -=  5;

          }

          else if (scrollDirection == "right")

          {

                    Object(this).content1.comic_content.comic.x +=  5;

          }

          else if (scrollDirection == "no")

          {

                    Object(this).content1.comic_content.comic.x +=  0;

          }

}

//

Object(this).content1.movie_content.btn1.addEventListener(MouseEvent.MOUSE_DOWN, btn1);

function btn1( event:MouseEvent):void

{

          addChild(flvPlayer);

          flvPlayer.source = myVideo[0];

}

Object(this).content1.movie_content.btn2.addEventListener(MouseEvent.MOUSE_DOWN, btn2);

function btn2( event:MouseEvent):void

{

          addChild(flvPlayer);

          flvPlayer.source = myVideo[1];

}

Object(this).content1.movie_content.btn3.addEventListener(MouseEvent.MOUSE_DOWN, btn3);

function btn3( event:MouseEvent):void

{

          addChild(flvPlayer);

          flvPlayer.source = myVideo[2];

}

function endAll()

{

flvPlayer.stop();

removeChild(flvPlayer);

}

//

import fl.video.*;

var myVideo:Array = ["The Avengers.mp4","The Avengers2.mp4","The Avengers3.mp4"];

var myTitle:Array = ["Estrella - Stay","Everyone Connect - Bunkface","Marvel Intro"];

var flvPlayer:FLVPlayback = new FLVPlayback();

//flvPlayer.skin = "skin/MinimaFlatCustomColorPlayBackSeekCounterVolMute.swf";

flvPlayer.skinBackgroundColor = 666666;

flvPlayer.skinBackgroundAlpha = 0.85;

flvPlayer.scaleMode = "maintainAspectRatio";

flvPlayer.width = 400;

flvPlayer.height = 225;

flvPlayer.x = 560;

flvPlayer.y = 360;

flvPlayer.align = "center";

this is mycode for the website.. and this problem keep coming went i clik other buttton

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.

          at flash.display::DisplayObjectContainer/removeChild()

          at edited_fla::MainTimeline/endAll()

          at edited_fla::MainTimeline/character()

pls help me...

This topic has been closed for replies.

3 replies

Participant
August 20, 2013

A simple solution I just thought of to this is as follows:

if(parent.contains(child)){

     removeChild(child)

}

Hope this helps you or anyone else who has a similar problem!

April 12, 2013

Test for Child existence.

if (flvPlayer)

{

     removeChild(flvPlayer);

}

Inspiring
April 12, 2013

if(flvPlayer && flvPlayer.parent)

{

     removeChild(flvPlayer);

}

Most likely the error occur because you try to remove the player when it has been already removed.

_spoboyle
Inspiring
May 15, 2012

the error is saying for some reason that the flvplayer is not a child of the objet you are trying to remove it from.

has the flvplayer been added to the stage by the time you get this message

change

function endAll()

{

flvPlayer.stop();

removeChild(flvPlayer);

}

to

function endAll()

{

trace("flvPlayer parent: " + flvPlayer.parent);

flvPlayer.stop();

removeChild(flvPlayer);

}

and let me know the result.

if it's just not added yet

you could use

function endAll()

{

flvPlayer.stop();

if (contains(flvPlayer)

{

removeChild(flvPlayer);

}

}

but if has been added but just to a different object the above suggestion wont clear things up properly

Participant
May 15, 2012

nvm, i just use workarround, flvPlayer.source=empty.mp4.. but u got any other solution?

_spoboyle
Inspiring
May 16, 2012

your work arround doesn;t remove the flvplayer from the stage so I not sure what you want a solution for any more

also i need you to do what i asked so i can understand the situation better before i cna offer a different solution