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

  • SEARCH
  • Home
  • 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 8793539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:08:06+00:00 2026-06-13T23:08:06+00:00

Using KineticJS, i’ve been trying to create a group that has just a circle

  • 0

Using KineticJS, i’ve been trying to create a group that has just a circle and 4 rectangles, but when clicked, it will have the rectangles appear around them (for options) and hide them on the next click. They have been created fine(i think ?) and i can get to the point where i have selected just the rectangles, but i need to use the Rect objects’ setVisible() function when the main circle is clicked to chance their states.

        function makePlayer(xPos, yPos) {
            var bufferSize = 15;
            var player = new Kinetic.Group();
            var ball = new Kinetic.Circle({
                x: xPos,
                y: yPos,
                radius: 40,
                fill: 'black',
                stroke: 'black',
                strokeWidth: 1
            });
            player.add(ball);
            ball.setAttr("menuShow", false);


            for (var i = 0; i < 4; i++) {
                var menuBox = new Kinetic.Rect({
                    x: ball.getX(),
                    y: ball.getY(),
                    width: 50,
                    height: 50,
                    visible: false
                });
                if (i == 0) {
                    menuBox.setFill('red');
                    menuBox.setOffset(menuBox.getWidth() / 2, ball.getHeight() + bufferSize);
                    menuBox.on("click tap", function () { alert("red box clicked/tapped") });
                } else if (i == 1) {
                    menuBox.setFill('blue');
                    menuBox.setOffset(((ball.getWidth() / 2) * -1) - bufferSize, menuBox.getHeight() / 2);
                    menuBox.on("click tap", function () { alert("blue box clicked/tapped") });
                } else if (i == 2) {
                    menuBox.setFill('yellow');
                    menuBox.setOffset(menuBox.getWidth() / 2, ((ball.getHeight() / 2) * -1) - bufferSize);
                    menuBox.on("click tap", function () { alert("yellow box clicked/tapped") });
                } else if (i == 3) {
                    menuBox.setFill('white');
                    menuBox.setOffset(ball.getWidth() + bufferSize, menuBox.getHeight() / 2);
                    menuBox.on("click tap", function () { alert("white box clicked/tapped") });
                }
                menuBox.setAttr("menu", true);
                player.add(menuBox);
            }
            ball.on("click tap", function () {
                var menuPopup = ball.getAttrs();
                if (menuPopup.menuShow == false) {
                    for (var i = 1; i <= 4; i++) {
                        var menuBox = player.get('Rect');
                        menuBox.setVisible(true);
                    }
                }
            });

The circle spawns normally, but whenever they are clicked the code craps out at the setVisible, as previously stated.

This is the javascript error i get:
Uncaught TypeError: Object [object Object],[object Object],[object Object],[object Object] has no method ‘setVisible’

  • 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-13T23:08:07+00:00Added an answer on June 13, 2026 at 11:08 pm

    I don’t know kinectjs but I have to wonder if it might have something to do with the way you’re adding and showing the menus. You don’t use the loop variables to identify a specific menu. For example, it seems like you might create the menuBox into an array or with a name concatenated with the number. Then, in the click/tap handler loop you probably want to reference the individual menus the same way.

    In looking over it again, it seems the player.get(‘Rect’) line is returning an array of items that match. So, I suspect the real solution to your problem is to ignore my first paragraph and instead change the tap handler’s loop line to the following:

    menuBox[i-1].setVisible(true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to animate an image using KineticJS to move across the screen, but
I'm trying to figure out why creating a canvas using KineticJS isn't working on
I've been playing about with the KineticJs JavaScript library and now I'm trying to
I'm trying to build a web app using KineticJS, I basically have a function
Hey I am implementing the drag and drop operations using Kineticjs Now I want
Using InteliJ IDEA , I am trying to set up multiple projects to run
Using System.Diagnostics.EventLog .NET type one can programmatically create logs into the Event Viewer application.
I am using the latest kineticjs.(v.3.10) Here is the problem I am using a
I'm tasked with building an app that would recreate an image using words and
Can I implement snap to grid operation with images in KineticJS using jquery? (

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.