Copy link to clipboard
Copied
I cant seem to target a movieclip from a nested function it works fine from a function "ArgentinaBtn" that's called onClick... but cant target it if I place a function "defaultFade"within the function"ArgentinaBtn". Please anyhelp 🙂
function defaultFade() {
//alert("defaultFade worked!")
this.page_map.interactive_map.Argentina.alpha = 0.5;
this.page_map.interactive_map.Australia.alpha = 0.5;
this.page_map.interactive_map.Austria.alpha = 0.5;
}
this.page_map.interactive_map.Argentina.addEventListener("click", ArgentinaBtn.bind(this));
function ArgentinaBtn()
{
//this.page_map.interactive_map.Argentina.alpha = 0.5;
//this.page_map.interactive_map.Australia.alpha = 0.5;
//this.page_map.interactive_map.Austria.alpha = 0.5;
defaultFade();
//overwrite
this.page_map.interactive_map.Argentina.alpha = 1;
}
s
Hi.
The context of the defaultFade function is not the main timeline but rather the window object. You need to bind the defautFade function to the main timeline.
One way of doing this in your code is to replace the call:
defaultFade();
By:
defaultFade.call(this);
But I think it's easier in most cases to store a reference to the main timeline in a variable. Like this:
var root = this;
function defaultFade()
{
root.page_map.interactive_map.Argentina.alpha = 0.5;
root.page_map.interactive_
...
Copy link to clipboard
Copied
Hi.
The context of the defaultFade function is not the main timeline but rather the window object. You need to bind the defautFade function to the main timeline.
One way of doing this in your code is to replace the call:
defaultFade();
By:
defaultFade.call(this);
But I think it's easier in most cases to store a reference to the main timeline in a variable. Like this:
var root = this;
function defaultFade()
{
root.page_map.interactive_map.Argentina.alpha = 0.5;
root.page_map.interactive_map.Australia.alpha = 0.5;
root.page_map.interactive_map.Austria.alpha = 0.5;
}
function ArgentinaBtn()
{
defaultFade();
root.page_map.interactive_map.Argentina.alpha = 1;
}
root.page_map.interactive_map.Argentina.addEventListener("click", ArgentinaBtn);
I hope it helps.
Regards,
JC
Copy link to clipboard
Copied
thanks that perfect... i thought i had tried that.
Copy link to clipboard
Copied
You're welcome.