Copy link to clipboard
Copied
If I have a movieclip symbol which has a simple clickable action to hide another object on the HTML canvas, however the object I want to be clickable is in a group, but the object I am setting visible to false is not in this group.
Have tried using the actions and code snippets to set this, but is not working, am wondering if I have to reference it differently because 'bind(this)' or 'this.movieClip_1.visible' is only looking for objects within the group??
Thanks
Copy link to clipboard
Copied
Hi.
What you call a group is a Movie Clip, I suppose.
So here is a code to make a button inside of a Movie Clip to set another button inside of another Movie Clipe invisible and also set a button in the main timeline to also be invisible.
var that = this;
this.group0.button.addEventListener("click", function()
{
// object inside of a movie clip called 'group1'
that.group1.button.visible = false;
// object in the main timeline
that.button.visible = false;
});
Copy link to clipboard
Copied
Thanks, kind of.
Also, can I ask why you use 'var that = this;' ?
It is a movieclip symbol (m1), combined with other objects into a group (g1) (Modify > Group), then this group converted to a movieclip symbol so can give it an instance name.
Then I can show/hide the entire group with one command
Problem I was having is applying a link to the movieclip symbol within the group to target an object (m3) outside of the group.
However, steered by your code I found that by adding the group instance name to the 'this. eventlistener' line it worked, I guess by identifying the clickable symbol was in a group and not referencing this group in the .visible request it figured it out.
this.g1.m1.addEventListener("click", fl_ClickToHide.bind(this));
function fl_ClickToHide()
{
this.m3.visible = false;
}
So, all working now , thanks
Copy link to clipboard
Copied
Nice!
Just two things:
- Groups can't be referenced in code. It's just an organization feature for the authoring time.
- I used 'var that = this' because of scope. 'this' in the main timeline and 'this' inside of a function may refer to different objects. That's why the 'that' variable is handy because it stores a reference to the main timeline no matter where it is used.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now