Skip to main content
Participant
December 5, 2017
Answered

HOW TO REPLACE / SWAP AN IMAGE WITH ANIMATION IN ANIMATE CC + CREATEJS?

  • December 5, 2017
  • 1 reply
  • 3583 views

In animate cc I have an animation made on timeline for "image 01"

how to replace in runtime the "image 01" for another external image AND preserving the animation timeline for this new image?

I was able to insert image 01 and insert an external image 02 with CreateJs, but this second image comes without the animation.

This is my code, It replaces image 01 for image 02, but the animation does not work on image 02

wthis = this;

var preload = new createjs.LoadQueue();

this.loadImage = function (wthis) {

     preload.addEventListener("fileload", handleFileComplete);

     preload.loadFile({

         src: "images/2.jpg",

         id: 'img2'

     });

}

function handleFileComplete(event) {

     var img2= preload.getResult("img2");

     var bmp = new createjs.Bitmap(img2);

     wthis.Img1.addChild(bmp);

}

this.bt2.addEventListener("click", f_MouseClickHandler.bind(this));

function f_MouseClickHandler()

{

     wthis.Img1.gotoAndPlay(2);

}

This topic has been closed for replies.
Correct answer kglad

animate a movieclip.

use addChild to add your image to the animated movieclip.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
December 6, 2017

animate a movieclip.

use addChild to add your image to the animated movieclip.