Using variables to reference symbols in HTML canvas.
I'm trying to create a banner that just plays symbols one at a time. The number of symbols will change as we create them. When a symbol finishes playing it calls a function that fades it out and fades-in and starts playing the next one. It's basically a content slider without any controls.
How can I do this using variables rather than hard coding instance names?
At the end of the symbol's animate this is triggered in its timeline.
this.getStage().getChildAt(0).changeSlide(1);
1 in the function name is the order number of the symbol which in this case is called symbol1
Here is the function on the stage:
this.changeSlide = function(slideNum)
{
var totalnumSlides = 4;
var nextSlide;
var self = this;
self.curSlide = "self.symbol"+slideNum;
if (slideNum == numSlides)
{
nextSlide = "self.symbol1"
}
else {
slideNum ++;
nextSlide = "self.symbol" + slideNum;
}
createjs.Tween.get(curSlide).to({alpha:0}, 1000);
nextSlide.gotoAndPlay(0);
createjs.Tween.get(nextSlide).to({alpha:1}, 1000);
}
Needless to say, this does not work. using nextSlide in gotoAndPlay is undefined and using curSlide in the createjs line I've attempted to assign a readonly property. I could use some help. Thanks.
