Copy link to clipboard
Copied
How to display a movieclip when button is clicked in animate cc (canvas html5).
I hope someone can help me. thanks.
Hi.
Two ways of doing this is making the Movie Clip visible or adding from the library. It depends on what you want.
Assuming that you have a Movie Clip on the stage called 'mc' that has its visible property unchecked in the Properties panel and it has a linkage name of "Rectangle" in the Library panel. And you also have two buttons called 'buttonVisble' and 'buttonAdd' on the stage, add this code to the main timeline:
...var that = this;
this.buttonVisible.addEventListener("click", makeVisible);
this.b
Copy link to clipboard
Copied
Hi.
Two ways of doing this is making the Movie Clip visible or adding from the library. It depends on what you want.
Assuming that you have a Movie Clip on the stage called 'mc' that has its visible property unchecked in the Properties panel and it has a linkage name of "Rectangle" in the Library panel. And you also have two buttons called 'buttonVisble' and 'buttonAdd' on the stage, add this code to the main timeline:
var that = this;
this.buttonVisible.addEventListener("click", makeVisible);
this.buttonAdd.addEventListener("click", addFromLibrary);
function makeVisible(e)
{
that.mc.visible = true;
}
function addFromLibrary(e)
{
that.addChild(new lib.Rectangle());
}
Working example: here.
Regards,
JC
Copy link to clipboard
Copied
Hi,
Is there anyway to load dynamic symbol from library?
I created different linkage names for sybmols and would need to load one of them each time according to the button event I click. Then I need to scroll the dynamically loaded movieClip within certain area on the stage.
Thanks in advance
Copy link to clipboard
Copied
ok! its work. thank you very much.
but, how to set an movieclip potition on stage if to fit as my wish?
thanks for your help.
how to set the movie clip layout in stage
Copy link to clipboard
Copied
This is great!
Like this:
var that = this;
this.buttonVisible.addEventListener("click", makeVisible);
this.buttonAdd.addEventListener("click", addFromLibrary);
function makeVisible(e)
{
that.mc.x = 400;
that.mc.y = 100;
that.mc.visible = true;
}
function addFromLibrary(e)
{
// store the object in a variable
var rec = new lib.Rectangle();
rec.x = 150;
rec.y = 250;
that.addChild(rec);
// or add directly
//that.addChild(new lib.Rectangle());
}
Please don't hesitate to ask if you have any further questions.
Regards,
JC
Copy link to clipboard
Copied
one more problem, how to unload movie clip in different timeline?
sorry for my questions. I just learn to adobe animate (html5 canvas).
Thanks
god bless you
Copy link to clipboard
Copied
What do you mean in different timeline?
Copy link to clipboard
Copied
how unload movie clip is not in current timeline?
Copy link to clipboard
Copied
Do you mean timelines of other symbols? Like a Movie Clip inside another Movie Clip, a button inside of another Movie Clip, and so on?
If it is, you can use dot notation and call the method removeChild.
Let's say in our example we add another Movie Clip inside 'mc' called 'childMc'. And we add a button called 'buttonRemoveChild' just to remove the 'childMc'. Our code will be:
var that = this;
this.buttonRemoveChild.addEventListener("click", removeChild);
function removeChild()
{
that.mc.removeChild(that.mc.childMc);
}
Notice that the methods addChild and removeChild have to be called by the parent.
Copy link to clipboard
Copied
can you give me a example project JoãoCésar​? thanks very much
Copy link to clipboard
Copied
Sure.
Here we go: show_add_movie_clips_html5.
Copy link to clipboard
Copied
ok. thanks, but i cant open it. i use animate cc 2017. how can fix trouble?
Copy link to clipboard
Copied
Animate CC won't let me save an FLA to older versions.
What I can do is to save as a .xfl and you try to open and see if it works: show_add_movie_clips_html5_xfl.
Anyway, the best you can do is to open the Adobe Creative Cloud app and upgrade your Animate 2017 to the 2018 version and then your are going to be able to open the file, besides getting lot of bug fixes and some new cool features.
Regards,
JC
Copy link to clipboard
Copied
hi, JoãoCésar​ now im use animate cc 2018. but your file show_add_movie_clips_html5​ still can't open it. any solution for me?
thanks
Regards
Chanz
Copy link to clipboard
Copied
Hi again.
Are you trying to open the .zip file in Animate or the .fla inside the .zip file?
You have to first extract the .zip file and then run the .fla.
Copy link to clipboard
Copied
Is there a way to load these movieclips on layers, i made different scripts on different layers but the last loaded movieclip is always in front of the other and i want to preserve the layers,