Skip to main content
Romain29189298g7i4
Participating Frequently
May 7, 2023
Answered

How to make a line between to movieClip inside a MovieClip?

  • May 7, 2023
  • 1 reply
  • 383 views

Hi everybody

I'm trying to convert AS3 to HTML and I need to call a MovieClip from the library, and inside the movieClip I have tow clips and I want make a line between the both.

I write this code, but he don't want work (I'm french and very beginner)

"

let root = this;

var MakeTheLine = new createjs.Shape();

let Line_mc = new lib.LineMovieClip();

this.addChild(Line_mc);
Line_mc.x=100;
Line_mc.y=100;

function MakeTheLine(){
MakeTheLine.graphics.clear();
MakeTheLine.graphics.setStrokeStyle(3);
MakeTheLine.graphics.beginStroke("#000000");
MakeTheLine.graphics.moveTo(Line_mc.Dot1.x,Line_mc.Dot1.y);
MakeTheLine.graphics.lineTo(Line_mc.Dot2.x,Line_mc.Dot2.y);

}
MakeTheLine()

"

Thanks for everything

Romain

    This topic has been closed for replies.
    Correct answer kglad

    you're welcome.

    1 reply

    kglad
    Community Expert
    Community Expert
    May 8, 2023

    you have several problems.  the first is using the same name for a shape as for a function.  then you fail to add and position the shape on the stage.

     

    let root = this;

    var MakeTheLine = new createjs.Shape();
    this.addChild(MakeTheLine);

    let Line_mc = new lib.LineMovieClip();

    this.addChild(Line_mc);
    MakeTheLine.x = Line_mc.x = 100;
    MakeTheLine.y = Line_mc.y = 100;

    function MakeTheLineF() {
    MakeTheLine.graphics.clear();
    console.log(MakeTheLine.graphics)
    MakeTheLine.graphics.setStrokeStyle(3);
    MakeTheLine.graphics.beginStroke("#0000ff");
    MakeTheLine.graphics.moveTo(Line_mc.Dot1.x, Line_mc.Dot1.y);
    MakeTheLine.graphics.lineTo(Line_mc.Dot2.x, Line_mc.Dot2.y);
    }

    MakeTheLineF()

    Romain29189298g7i4
    Participating Frequently
    May 8, 2023

    Hello,

    thanks very much, that work very well!

    I made the movieclip and shape names mistake when I translate "my french name" in english,

    I think, my problème was I diden't do this :

    "MakeTheLine.x = Line_mc.x = 100;
    MakeTheLine.y = Line_mc.y = 100;"

    Thanks a lot.

    Romain

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    May 8, 2023

    you're welcome.