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 8813511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:52:12+00:00 2026-06-14T03:52:12+00:00

I have this stage associated to a container: html: <div id=container> script 1: var

  • 0

I have this stage associated to a container:

html:

<div id="container">

script 1:

var stageInFirstScript = new Kinetic.Stage({
    container: document.getElementById('container'),
    width: this.SKETCH_WIDTH,
    height: this.SKETCH_HEIGTH
});

In a second script, I need to manipulate the shapes on the stage I just created. Is it possible to retrieve stageInFirstScript with something like this?

script 2:

var stageInSecondScript = document.getElementById('container').RetrieveExistingStage();
//now I have retrieved stageInFirstScript
//I can add shapes to it, etc....

Any help or alternative solution would be appreciated!

  • 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-14T03:52:13+00:00Added an answer on June 14, 2026 at 3:52 am

    You should be able to simply reference the variable you’ve created, that is “stageInFirstScript”. But if the two scripts are within two separate scopes, try making this variable global and then access it like one, like this (I’ll use jquery for this example):

    Script1.js:

    var stageInFirstScript; // declaring global variable
    
    $(window).load(function() {
    
       // assigning new stage to the global variable
    
       stageInFirstScript = new Kinetic.Stage({
           container: document.getElementById('container'),
           width: this.SKETCH_WIDTH,
           height: this.SKETCH_HEIGTH
       });
    
    });
    

    And then in script2.js:

    function doSomething() {
    
        // accessing global variable and calling its method
    
        stageInFirstScript.setHeight(300); 
    
    }
    

    This should work as long as the function is called after the variable has been defined, in this case after the window has been loaded.

    If you’re looking to get the stage of any container, one of the ways I can think of is to create an array associating kinetic stages with containers (or their ids for example).

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

Sidebar

Related Questions

I have this quickBox2d code to add a cricle to the stage: var ball:QuickObject
I haven't yet implemented this, I'm still in the thinking stage, but I have
I'm developing a html with this structure div id=menuContainer> <div class = menu ui-accordion-header
I have this code in my view: echo form_label('State', 'state'); $options = array( 'No
I have this function signature I have to match typedef int (*lua_CFunction) (lua_State *L);//target
I have this error message: Msg 8134, Level 16, State 1, Line 1 Divide
I have a list of lists that looks like this: x[[state]][[year]] . Each element
I have a text file, which looks like this: node13 state = free np
I have a JavaScript widget that is hosted on websites. This widget tracks state
This works when I have only one state code as a parameter. How can

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.