Changing the target of gotoAndStop
Using an HTML canvas with Animate, looking a the first three pages (frames) the first is the home page, the second a bio page, the third is a contact me page. On all pages are three common buttons: home, previous and next. The home botton always takes you back to the home page. The actions for the previous and next buttons will change depending on what page you are on: on the home page, the previous button will take you to the home page and the next button will take you to the bio page. On the bio page, the previous button will take you to the home page and the next button will take you to the contact me page. On the contact me page, the previous button will take you to the bio page and the next button will take you to the next page in the sequence.
At frame 15 I have defined the actions for all of the used in te Animate file. The definitions where the target of the gotoAndStop is static, such as the home page, it is pretty straightforward. However, I am having a difficult time for the next and previous button definitions. I first tried re-declaring the action at the first frame of these other pages but that did not seem to override the initial definition setup in frame 15. I then tried using a variable in the definition, such as (for the home page):
var _previous = home
var _next = bio
_this.previous_btn.on('click', function() {
_this.gotoAndStop(_previous);
})
_this.next_btn.on('click', function() {
_this.gotoAndStop(_previous);
})
This completely failed. The buttons did not perform any actions (with hardcoded 'home' and 'bio' the same code works).
Is it possible to dynamically change the target of a gotoAndStop/gotoAndPlay action?? Or, within the previous and next function definitions, will I need to determine where I am in the timeline and use IF/THEN or SWITCH constructs to vary the target of the button actions?
Thank you,
Al
