Hello!

I'm pretty new with javascript so sorry if this is a stupid question.

I have made a class. In this class i have added a Prototyped function "Game.prototype.ShowMessage"

Im calling this function from another prototyped function like this (Doing it twice)

Code:
this.ShowMessage(["Loading game", "Please wait..."]);
this.ShowMessage(["Loading game", "Please wait...","Loading gameLONGER", "Please wait...LONGER"],true);
Now i'm expecting to see two messages where one them will show twice as long as the first one called. But it seems like javascript is running in some kinda "sharing mode" which then suspends both functions when the first one is complete.

It works fine running these until the first call is done, then the other second call stops aswell.

Here is the function i'm trying to run twice (Note its the return false line which breaks both function. i tried to remove the return but it broke anyways).

Code:
 ///TODO CANNOT RUN "CONCURRENT" WITH MULTIPLE MESSAGES :/
        /// Shows a specefied message on the middle of the screen (Blinking), Also have a forever option which can be TRUE OR FALSE(default), IF true use callback to stop. 
        Game.prototype.ShowMessage = function (messageArray, forever, callback) {
            if (typeof forever == 'undefined') forever = false;

            // Since javascript cannot work in ??paralell?? We have to create a queue


            var flashText = new Pixi.Text("",
           {
               font: "70px Arial",
               fill: "white",
               stroke: '#000000',
               strokeThickness: 4
           });
            flashText.anchor = { x: 0.5, y: 0.5 };
            flashText.position.x = Conf.Data.width / 2;
            flashText.position.y = Conf.Data.height / 2;
            flashText.alpha = 0;
            flashText.forever = true;
            flashText.message = messageArray;
            flashText.tpmcallback = callback;
            flashText.countTo = messageArray.length;
            this.getGroup("Environment").addChild(flashText);


            position = { alpha: flashText.alpha };

            var tween = new TWEEN.Tween(position)
                .to({ alpha: 1 }, 2000)
                .easing(TWEEN.Easing.Elastic.InOut)
                .onUpdate(tweenUpdate)

            var tweenBack = new TWEEN.Tween(position)
                .to({ alpha: 0 }, 2000)
                .easing(TWEEN.Easing.Elastic.InOut)
                .onUpdate(tweenUpdate)
                .onComplete(tweenComplete);


            tween.chain(tweenBack);
            tweenBack.chain(tween);

            function tweenUpdate() {
                flashText.alpha = position.alpha;
            }

            function tweenComplete() {
                if (messageArray.length == 0) {
                    tween.stop();
                    return false
                }


                if (messageArray.length > 0) {
                    var msg = messageArray.shift();
                    flashText.setText(msg);
                }


                if (forever == true) {
                    messageArray.push(msg);
                    callback(tween); //May be used to call tween.stop();
                }
            }


            tween.start();
        }
Here i have a callback which is runned every time a "tween" is done. It checks if the "Forever" flag is set and if it is it pushes the Sentance which is in the input array back into the array. what this means is that this function should in theory NEVER stop. but instead it breaks when the other one breaks.

Going deeper: i'm talking about this snippet of code:
Code:
function tweenComplete() {
                if (messageArray.length == 0) {
                    tween.stop();
                    return false
                }


                if (messageArray.length > 0) {
                    var msg = messageArray.shift();
                    flashText.setText(msg);
                }


                if (forever == true) {
                    messageArray.push(msg);
                    callback(tween); //May be used to call tween.stop();
                }
            }

Can anyone see what that may be the problem here?
What should i do, not do to make these two functions run separate from each other?

Thanks
Driiper