<div id="container"></div>
html, body {
margin: 0;
padding: 0;
height: 100%;
background-color: #fff;
}
#container {
width: 100%;
height: 100%;
}
xxxxxxxxxx
import "https://cdn.skypack.dev/@next2d/player@latest";
const root = next2d.createRootMovieClip(240, 240, 60, {
"tagId": "container"
});
const { Sprite } = next2d.display;
const { MouseEvent } = next2d.events;
const {
TextField,
TextFormat,
TextFormatAlign
} = next2d.text;
const button = root.addChild(new Sprite());
button.name = "button";
button.x = 30;
button.y = 30;
button
.graphics
.beginFill("#7EA1C4")
.lineStyle(5, "#1B365C")
.drawCircle(50, 50, 40);
const textFormat = new TextFormat();
textFormat.size = 12;
textFormat.color = "#fff";
textFormat.bold = true;
textFormat.align = TextFormatAlign.CENTER;
const textField = button.addChild(new TextField());
textField.defaultTextFormat = textFormat;
textField.autoFontSize = true;
textField.width = 50;
textField.height = 15;
textField.x = 25;
textField.y = 44;
textField.text = "click";
button.buttonMode = true;
button.addEventListener(MouseEvent.CLICK, (event) =>
{
const { Sprite } = next2d.display;
const { Event } = next2d.events;
const {
TextField,
TextFormat,
TextFormatAlign
} = next2d.text;
const target = event.currentTarget;
target.buttonMode = false;
target.removeEventListener(MouseEvent.CLICK, event.Listener);
const parent = target.parent;
const sprite = new Sprite();
sprite.name = "addedSprite";
sprite.x = 120;
sprite.y = 120;
sprite
.graphics
.beginFill("#7EA1C4")
.lineStyle(5, "#1B365C")
.drawCircle(50, 50, 40);
const textFormat = new TextFormat();
textFormat.size = 12;
textFormat.color = "#fff";
textFormat.bold = true;
textFormat.align = TextFormatAlign.CENTER;
const textField = sprite.addChild(new TextField());
textField.defaultTextFormat = textFormat;
textField.name = "state";
textField.autoFontSize = true;
textField.width = 50;
textField.height = 15;
textField.x = 25;
textField.y = 44;
textField.text = "non added.";
sprite.addEventListener(Event.ADDED_TO_STAGE, (event) =>
{
const target = event.currentTarget;
target.state.text = Event.ADDED_TO_STAGE;
});
parent.addChild(sprite);
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.