Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9091737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:41:02+00:00 2026-06-16T22:41:02+00:00

I am creating rectangle nodes with a for() statement and now I need to

  • 0

I am creating rectangle nodes with a for() statement and now I need to get the reference to each one. There seams to to be some black magic going on to create these canvas objects ,so it makes it hard to access items without ids to reference.
Can someone clear this up or point me in the right direction?

for(x=1;x<=8;x++)
  {

  var rect = new Kinetic.Rect({
    x: 300,
    y: 80+offset,
    width: 60,
    height: 20,
    fill: 'white',
    stroke: 'black',
    strokeWidth: 1,
    draggable: false
  });
rect.on('mouseover', function() {
    writeMessage(messageLayer, this.getY());
  });
  // add the shape to the layer
  layer.add(rect);

offset += 120;

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:41:03+00:00Added an answer on June 16, 2026 at 10:41 pm

    You should be able to access each of them buy using layer.getChildren();, which will return all of them, or if you know which one you need, layer.getChildren()[0];, which will get the first one.
    Though I would give them each a name to make it a bit easier.

    for(x=1;x<=8;x++)
    {
      var rect = new Kinetic.Rect({
      name: 'rct'+x,
      x: 300,
      y: 80+offset,
      width: 60,
      height: 20,
      fill: 'white',
      stroke: 'black',
      strokeWidth: 1,
      draggable: false
      });
    }
    

    Then you can use layer.get('.rct3'); or layer.get('.rct3')[0];.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm experimenting with some Piccolo to create a zoomable interface. I'm creating a rectangle
I've just finished creating a simple rectangle in OpenGL 3.2, now I want to
I am creating an application that can get text from the selected rectangle on
I am creating Dynamic Rectangle and adding into StackPanel . I need to add
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
Creating a simple RPG game, first time using XNA. Trying to get my character
I'm creating an SVG rectangle using the Raphael JavaScript library, and assigning it a
I need to split a rectangle (A CGRect structure which is {{float x,float y},{float
I am creating a Swing Application. I have one main JFrame and a JDesktopPane
I am creating a rectangle element which I want to later use as a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.