problem with return true and variable

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hey a problem of javascript again ;)

    I did a condition

    pluginProto.cnds = {};

    var cnds = pluginProto.cnds;


    cnds.ConfirmOKclicked = function ()


        if (confirmation=1)


        return true;     




        return false;



    confirmation is a var (its value change via actions) that I defined at the beginning of the runtime as following:

    var confirmation;

    I tried too:

    var confirmation=0;

    The problem is when the condition is used, from the beginning of the application, the return is obligatory true instead to be false...


  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • In instanceProto.onCreate = function()

    Make a variable this.confirmation = false;

    In cnds.ConfirmOKclicked

    return this.confirmation;

    this. makes that the variable is intriseque part of the plugin's runtime and its value is stored over the several blocks of code.

    The use of variable (their declaration and use) is directly tied to javascript.

    this. is also a "standard function" of Javascript.

    The SDK builds on this to make you use

    this.variable_name; to store your values and have access to them within the plugin, even once it is sealed.

    This is covered in the SDK - extract.

  • if (confirmation=1)

    A single = means assignment, so this statement means "assign 1 to confirmation and return 1", and since 1 is true the if statement is always true. You need two or three equals signs (e.g. confirmation === 1) to perform equality testing, generally three but make sure you're aware of the difference between using == and ===.

    This is a basic Javascript language question - it's best not to ask about the Javascript language itself in the forum, because there are much better places to learn Javascript on the web. From the SDK docs:

    ome useful resources for javascript are:

    Mozilla's Javascript Guide -

    A complete guide to javascript. This might be a good starting point if you are new to programming.

    StackOverflow -

    An excellent Q&A website. Also a good place to search to see if your question has already been asked and answered.

    Javascript Garden -

    Guide to the unusual parts of javascript. Very useful if you have experience with a different programming language but are new to javascript.

    Mozilla Developer Network (MDN) -

    An excellent reference for HTML, javascript, and more. A very useful place to look up features for the browser side of the plugin.edited><editID>Ashley</editID><editDate>2011-11-20 16:40:36</editDate></edited>

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)