How to add a dynamically created graphic to a frame on a timeline?

I have:
myButton = new createjs.MovieClip({
loop: -1,
labels: { up: 1, over: 2, down: 3, disabled: 4 },
});

How can I create a a graphic and add it just to frame "over"?

I have not done that before but if you are wanting it for a button, the ZIM Button() has two ways to do it, one as backing or rollBacking and the other as icon or rollIcon parameters.

new Button({
    backing:pic1,
    rollBacking:pic2
}).center()

In general, with code without a MovieClip or a Button, this is done with a "mouseover" and "mouseout" event on an object.

const container = new Container().cur().loc(100,100);
pic1.addTo(container);

container.on("mouseover", ()=>{
    container.removeAllChildren(); 
    pic2.addTo(container);
    S.update();
});
container.on("mouseout", ()=>{
    container.removeAllChildren(); 
    pic1.addTo(container);
    S.update();
});

Thanks! I'll see if I can get it working that way. I'm still seeing all that ZIM has to offer!

1 Like