mexicanChica
mexicanChica

Reputation: 69

Why does exportRoot not place movieclip on canvas using createjs and animate cc?

I have created a movie clip called firework_mc in the library and wrote the following code hoping to place it on the canvas:

var movieClip = exportRoot.firework_mc.play();
movieClip.x=100;
movieClip.y=100;

I was hoping this would work but clearly not. Any other ideas on how to place it on the canvas?

Upvotes: 0

Views: 1335

Answers (1)

Lanny
Lanny

Reputation: 11294

The play method does not return a MovieClip instance. So your movieclip instance is null.

You should be able to do this:

var movieclip = exportRoot.firework_mc;
movieclip.play();
movieclip.x = 100;
movieclip.y = 100;

There are some issues with Animate export where children aren't immediately available for control. You can usually get around this with a gotoAndStop up front.

exportRoot.gotoAndStop(0);
// Then your code.

This will only work if firework_mc is a child of the exportRoot (ie, on the stage in Animate). If it isn't, you can access it in the animate lib:

var movieclip = new lib.firework_mc();
stage.addChild(movieclip);
// Or
exportRoot.addChild(movieclip);

Cheers,

Upvotes: 1

Related Questions