• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Link a library symbol to a js Class

Community Beginner ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

Hi,

i've a symbol score in the library with a link ("Score").

I have the choice, for instanciate it, between :

 

var score1=new lib.Score();

 

then, i have the good graphics but i haven't any code associate to it.

 

var score1=new lib.Score();

 

then, i have all the functions and code associate to it but any graphics.

 

Is it possible to have a graphics link to a class, like with the as3 Class ? And if not, how to apporach of that ?

 

Thanks for your replies.

Views

170

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

In fact, i try to extend the createJS MovieClip class in an extern class Score.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

Hi.

 

I really didn't get what you want.

 

Do you mind providing a code example and/or an use case?

 

 

Regards,

JC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

this works but it's really not nice :

class Score {
    constructor(cible, x, y) {
        var key = Object.keys(AdobeAn.compositions)[0];
        var comp = AdobeAn.getComposition(key);
        var lib = comp.getLibrary();
        this.MC = new lib.Score();
        this.MC.x = x;
        this.MC.y = y;
        cible.addChild(this.MC);
    }
}

and i have to copy the 3 lines about AdobeAn in each class of this sort.

And that's composition instead of inheritance (i prefer the second for this type of class).

Maybe by transforming the library symbol into a component but i didn't find anything about that.

Thanks for your reply.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 05, 2021 Feb 05, 2021

Copy link to clipboard

Copied

LATEST

Hi.

 

Sorry for the delay.

 

So for me to understand: do you have a game and you want to add a score at runtime?

 

What exactly are you not being able to do?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines