i'm just new with Animate CC and trying to understand how it works.
I did this example:
(function (lib, img, cjs, ss) {
var p; // shortcut to reference prototypes
// library properties:
lib.properties = {
width: 1280,
height: 720,
fps: 60,
color: "#FFFFFF",
manifest: [
{src:"sounds/_30_reel.mp3?1472134036249", id:"_30_reel"}
]
};
// symbols:
(lib.Simbolo2 = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// Livello 1
this.shape = new cjs.Shape();
this.shape.graphics.f().s("#000000").ss(1,1,1).p("AImAAQAACqihB4QiiB4jjAAQjiAAiih4Qihh4AAiqQAAipChh4QCih4DiAAQDjAACiB4QChB4AACpg");
this.shape.setTransform(55,41);
this.shape_1 = new cjs.Shape();
this.shape_1.graphics.f("#0066CC").s().p("AmDEiQiih5AAipQAAipCih4QCgh4DjAAQDjAAChB4QChB4AACpQAACpihB5QihB4jjgBQjjABigh4g");
this.shape_1.setTransform(55,41);
this.shape_2 = new cjs.Shape();
this.shape_2.graphics.f("#FF0000").s().p("AmDEiQiih5AAipQAAipCih4QCgh4DjAAQDjAAChB4QChB4AACpQAACpihB5QihB4jjgBQjjABigh4g");
this.shape_2.setTransform(55,41);
this.shape_3 = new cjs.Shape();
this.shape_3.graphics.f("#000000").s().p("AmDEiQiih5AAipQAAipCih4QCgh4DjAAQDjAAChB4QChB4AACpQAACpihB5QihB4jjgBQjjABigh4g");
this.shape_3.setTransform(55,41);
this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.shape_1},{t:this.shape}]}).to({state:[{t:this.shape_2},{t:this.shape}]},1).to({state:[{t:this.shape_3},{t:this.shape}]},1).to({state:[{t:this.shape_1},{t:this.shape}]},1).wait(1));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(-1,-1,112,84);
(lib.Fx = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{Stop:29});
// timeline functions:
this.frame_0 = function() {
this.stop();
}
this.frame_29 = function() {
playSound("_30_reel");
}
// actions tween:
this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(29).call(this.frame_29).wait(1));
// Livello 1
this.shape = new cjs.Shape();
this.shape.graphics.f("#000000").s().p("AAHAnIAAgCIAFgBIACgBIABgCIAAgDIgDgFIgMgVIgRAWIgDAEIAAADIABADIAGABIAAACIgcAAIAAgCIAFgBIAHgEIAIgIIASgYIgPgVQgHgJgEgDQgEgDgGAAIAAgCIAkAAIAAACIgGABQAAABgBAAQAAAAAAABQAAAAgBAAQAAABAAAAQAAADADAEIAKASIAOgSIADgEIABgDIgBgCIgCgBIgFgBIAAgCIAcAAIAAACIgGABIgGAEIgHAIIgQAUIARAYQAHAKAEADQADADAGAAIAAACg");
this.shape.setTransform(13,8.8);
this.shape_1 = new cjs.Shape();
this.shape_1.graphics.f("#000000").s().p("AgdAnIAAgCIADAAQAFAAADgDQABgCAAgHIAAgxIgBgIIgDgDQgCgBgDAAIgDAAIAAgCIA5AAIABARIgBAAIgEgIQgCgDgDgBIgJgBIgQAAIAAAfIANAAQAFAAACgCQACgCABgHIACAAIAAAZIgCAAQAAgEgBgCQgBgBAAAAQAAgBgBAAQAAgBgBAAQAAgBgBAAIgFgBIgNAAIAAAZQAAAGABACIACADIAEABIACAAIAAACg");
this.shape_1.setTransform(5.2,8.8);
this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.shape_1},{t:this.shape}]}).to({state:[{t:this.shape_1},{t:this.shape}]},29).wait(1));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(0,0,19.5,17.5);
(lib.formabase = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{A:0,B:19});
// timeline functions:
this.frame_0 = function() {
this.stop();
}
this.frame_19 = function() {
this.stop();
}
// actions tween:
this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(19).call(this.frame_19).wait(1));
// Livello 1
this.shape = new cjs.Shape();
this.shape.graphics.f().s("#000000").ss(1,1,1).p("Az1spMAnrAAAIAAZTMgnrAAAg");
this.shape.setTransform(127,81);
this.shape_1 = new cjs.Shape();
this.shape_1.graphics.f("#0066CC").s().p("Az1MqIAA5TMAnqAAAIAAZTg");
this.shape_1.setTransform(127,81);
this.shape_2 = new cjs.Shape();
this.shape_2.graphics.f("#FF0066").s().p("Az1MqIAA5TMAnqAAAIAAZTg");
this.shape_2.setTransform(127,81);
this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.shape_1},{t:this.shape}]}).to({state:[{t:this.shape_2},{t:this.shape}]},19).wait(1));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(-1,-1,256,164);
(lib.Simbolo1 = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// timeline functions:
this.frame_0 = function() {
this.stop();
}
// actions tween:
this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(40));
// Livello 1
this.ani2 = new lib.formabase();
this.ani2.setTransform(127,81,1,1,0,0,0,127,81);
this.timeline.addTween(cjs.Tween.get(this.ani2).to({x:663,y:-3},39).wait(1));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(-0.5,-0.5,255,163);
// stage content:
(lib.index = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// timeline functions:
this.frame_0 = function() {
this.button.addEventListener("click", fl_ClickToPosition.bind(this));
function fl_ClickToPosition() {
this.ani.ani2.gotoAndStop("B");
this.ani.play();
}
}
// actions tween:
this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(1));
// Fx
this.fx = new lib.Fx();
this.fx.setTransform(390.8,85,1,1,0,0,0,9.8,8.7);
new cjs.ButtonHelper(this.fx, 0, 1, 2, false, new lib.Fx(), 3);
this.timeline.addTween(cjs.Tween.get(this.fx).wait(1));
// Livello 1
this.button = new lib.Simbolo2();
this.button.setTransform(121,160,1,1,0,0,0,55,41);
new cjs.ButtonHelper(this.button, 0, 1, 2, false, new lib.Simbolo2(), 3);
this.ani = new lib.Simbolo1();
this.ani.setTransform(485,292,1,1,0,0,0,127,81);
this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.ani},{t:this.button}]}).wait(1));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(705,436.3,547.5,297.3);
})(lib = lib||{}, images = images||{}, createjs = createjs||{}, ss = ss||{});
var lib, images, createjs, ss;
and it works fine.
Now I'm wondering how can achieve this behaviour to move the ani2 to label "B" from another Javascript file. If I try to put this code this.ani.ani2.gotoAndStop("B"); in the html it doesn't work. What I'm missing?
thank you very much
This could be due to an initialization bug, where you can't call gotoAndStop
immediately after initialization.
Just to test this, I added the following lines to the html file generated by Adobe Animate:
exportRoot.ani.gotoAndStop(0);
exportRoot.ani.ani2.gotoAndStop(19);
The first line forces a child/timeline update on the ani
clip, which makes the 2nd line work properly.
This is a known issue, and on the short list to solve for the next version of CreateJS that will be included in Adobe Animate.
Cheers.