0

I have two functions here

function Preloader() {}
Preloader.prototype = {
    init:function() {
        // do something
    }
}

var preloader = new Preloader();

function Project() {}
Project.prototype = {
    init:function() {
        // do something else 
    }
}

var project = new Project();

I want to call project.init() in preloader's init function but obviously

project.init()

doesn't work 'cause there's no project variable in preloader. How should I call it? Thanks!

2
  • 1
    Why would you want to do that? You can pass the Project instance you wish to call init() on to the Preloader init() function? Commented Jun 18, 2012 at 18:44
  • I need to wait till a tween to end in preloader.init then call project.init. Commented Jun 18, 2012 at 23:39

1 Answer 1

2
Preloader.prototype = {
    init:function(project) {
        project.init();
    }
}

var preloader = new Preloader(),
    project = new Project();

preloader.init(project);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.