Skip to main content
Participating Frequently
December 11, 2017
Answered

load a movieclip html5 canvas

  • December 11, 2017
  • 3 replies
  • 6835 views

How to display a movieclip when button is clicked in animate cc (canvas html5).

I hope someone can help me. thanks.

This topic has been closed for replies.
Correct answer JoãoCésar17023019

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

3 replies

Participating Frequently
December 11, 2017

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

JoãoCésar17023019
Community Expert
Community Expert
December 11, 2017

What do you mean in different timeline?

Participating Frequently
December 11, 2017

how unload movie clip is not in current timeline?

Participating Frequently
December 11, 2017

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
JoãoCésar17023019
Community Expert
Community Expert
December 11, 2017

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

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
December 11, 2017

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

Participant
March 12, 2021

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