Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

removing an attached movieclip showing error??

New Here ,
Jul 03, 2011 Jul 03, 2011

Im using this code to attach a movieclip when mouse over and also on mouse out the movieclip shoud remove itself however this is not working

CODE:

s_talk.addEventListener(MouseEvent.MOUSE_OVER, attachMovieclip);
function attachMovieclip (e:MouseEvent):void {
var addtalk1:talk1 = new talk1();
addtalk1.x= 1120  
addtalk1.y= 0
this.addChild(addtalk1);
}
s_talk.addEventListener(MouseEvent.MOUSE_OUT, removeMovieclip);
function removeMovieclip (e:MouseEvent):void {
var addtalk1:talk1
removeChild(addtalk1);
}

When i test the flash and hover over the button the movie attachs correctly however when i mouse out nothing happens and the output section in adobe flash shows the error message:

TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/removeChild()
    at Untitled_fla::MainTimeline/removeMovieclip()

TOPICS
ActionScript
415
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 03, 2011 Jul 03, 2011

try declaring the variable once outside of the functions:

var addtalk1:talk1 = new talk1();

s_talk.addEventListener(MouseEvent.MOUSE_OVER, attachMovieclip);
function attachMovieclip (e:MouseEvent):void {

addtalk1.x= 1120  
addtalk1.y= 0
addChild(addtalk1);
}
s_talk.addEventListener(MouseEvent.MOUSE_OUT, removeMovieclip);
function removeMovieclip (e:MouseEvent):void {
removeChild(addtalk1);
}

Translate
Community Expert ,
Jul 03, 2011 Jul 03, 2011

try declaring the variable once outside of the functions:

var addtalk1:talk1 = new talk1();

s_talk.addEventListener(MouseEvent.MOUSE_OVER, attachMovieclip);
function attachMovieclip (e:MouseEvent):void {

addtalk1.x= 1120  
addtalk1.y= 0
addChild(addtalk1);
}
s_talk.addEventListener(MouseEvent.MOUSE_OUT, removeMovieclip);
function removeMovieclip (e:MouseEvent):void {
removeChild(addtalk1);
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 03, 2011 Jul 03, 2011
LATEST

THANKS YOU THANK YOU

Works awesomely

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines