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

Naming a new instance of a movie clip

Participant ,
Mar 23, 2025 Mar 23, 2025

Hi

In an HTML5 canvas, I've managed to create an instance of a movie clip (a ball) and I've used the .name property to give it an instance name, but when I try to use that instance name to play the timeline inside that movie clip, it says 'can't find variable' or 'undefined is not an object' if I add root.

If I don't name it and just use'ball', when I try ball.play(), it loops through all the different movie clips in the library.

What am I doing wrong?

var ball = new lib.ball()
ball.name = "ball1_mc"
ball.scaleX = 0.3
ball.scaleY = 0.3
ball.regX = ball.getBounds().width / 2
ball.regY = ball.getBounds().height
ball.x = this.shelfB4_x
ball.y = this.shelfB_y
this.addChild(ball)

ball.on("click", clickBall)

function clickBall() {
ball1_mc.play()
}
TOPICS
Code , How to
66
Translate
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
no replies

Have something to add?

Join the conversation