Copy link to clipboard
Copied
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()
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);
}
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
THANKS YOU THANK YOU
Works awesomely
Find more inspiration, events, and resources on the new Adobe Community
Explore Now