Hello!
I am trying to add some code to AS3 so that when the user clicks on an image (movie clip), another, which is hidden at that moment, appears on the screen.
This is what I have done so far on Actions frame:
import flash.display.MovieClip;
boton.buttonMode = true;
boton.addEventListener(MouseEvent.CLICK, clickPag13);
function clickPag13(event:MouseEvent):void {
var minuevoMC:MovieClip = getChildByName('mymovieclip') as MovieClip;
if (minuevoMC.visible == true) {minuevoMC.visible = false}
else {minuevoMC.visible = true}
}
- import flash.display.MovieClip;
- boton.buttonMode = true;
- boton.addEventListener(MouseEvent.CLICK, clickPag13);
- function clickPag13(event:MouseEvent):void {
- var minuevoMC:MovieClip = getChildByName('mymovieclip') as MovieClip;
- if (minuevoMC.visible == true) {minuevoMC.visible = false}
- else {minuevoMC.visible = true}
- }
where boton is the name of the movieclip the user has to click on,
and mymovieclip is the movieclip that will appear on the screen.
But it doesn't work.
I get the following Error in Output:
TypeError: Error #1009: No se puede acceder a una propiedad o a un método de una referencia a un objeto nulo.
at flashworks_fla::MainTimeline/clickPag13()
which means something like the property or method of the reference of a null object can not be accessed at..
any idea, please, as to how can I solve this?
thank you and regards.