Answered
Hide object/image one by one
Hey, I am new to adobe animate.. how to hide object/image one by one by clicking the same button multiple times?
Hey, I am new to adobe animate.. how to hide object/image one by one by clicking the same button multiple times?
Two approaches would be using array access (bracket notation) or storing the pencils in a vector or array.
Array access (bracket notation):
import flash.display.MovieClip;
import flash.events.MouseEvent;
var counter:int = 10;
minusbtn.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void
{
MovieClip(root)["pencil" + counter--].visible = false;
if (counter == 0)
e.currentTarget.removeEventListener(e.type, arguments.callee);
});
Vector / Array:
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.events.MouseEvent;
var pencils:Vector.<DisplayObject> = new <DisplayObject>
[
pencil1,
pencil2,
pencil3,
pencil4,
pencil5,
pencil6,
pencil7,
pencil8,
pencil9,
pencil10
];
minusbtn.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void
{
pencils.pop().visible = false;
if (pencils.length == 0)
e.currentTarget.removeEventListener(e.type, arguments.callee);
});
Regards,
JC
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.