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

CreateEmptyMovieClip HTML5

Explorer ,
Oct 17, 2020 Oct 17, 2020

Copy link to clipboard

Copied

Hello,
Is there a handy HTML5 equivalent of "createEmptyMovieClip" in ActionScript 2? This would allow you to draw with MoveTo and lineTo and make the drawing move.
Thank you for your answer.

Views

259

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

correct answers 1 Correct answer

Explorer , Oct 18, 2020 Oct 18, 2020

Problem solved. I removed the moveTo from the ticker and deleted endStroke().

Votes

Translate

Translate
Community Expert ,
Oct 17, 2020 Oct 17, 2020

Copy link to clipboard

Copied

Hi.

 

In HTML5 Canvas you use the new keyword and the class constructor. Like this:

 

var shape = new createjs.Shape();
shape.graphics.beginStroke("#000000");
shape.graphics.moveTo(0, 0);
shape.graphics.lineTo(100, 100);
shape.graphics.endStroke();
this.addChild(shape);

 

 

It can be an instance from MovieClip, Sprite, Container or any other Display object.

 

I hope this helps.

 

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
Explorer ,
Oct 17, 2020 Oct 17, 2020

Copy link to clipboard

Copied

Thank you very much Mr. JoãoCésar. This is exactly what I needed. So I was able to write the following code but does it show a dotted line ? I've been stuck on this for too long and I need your expertise again. Thanks again.

 

var myPoint = {x:400, y:100}

createjs.Tween.get(myPoint,{loop: -1})
.to({x:400, y: 100}, 1000)
.wait(200)
.to({x:400, y: 150}, 1000)
.wait(200)
.to ({x:400, y: 100}, 1000)
.wait (200)

var A;
var B;
var C;
var D;
var E;

var shape = new createjs.Shape();
shape.graphics.beginStroke("#000000");

createjs.Ticker.addEventListener("tick", tick.bind(this));
function tick()
{
A = myPoint.x;
B = myPoint.y;
C = shape.x;
D = A - C;
E = D + 1;
shape.graphics.beginStroke("#000000");
shape.graphics.moveTo( D, B );
shape.graphics.lineTo( E, B );
shape.graphics.endStroke();
app.addChild(shape);
shape.x+= +0.51;
};

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
Explorer ,
Oct 17, 2020 Oct 17, 2020

Copy link to clipboard

Copied

Missing: app = this;

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
Explorer ,
Oct 18, 2020 Oct 18, 2020

Copy link to clipboard

Copied

LATEST

Problem solved. I removed the moveTo from the ticker and deleted endStroke().

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