• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

arrays and loading movies

New Here ,
Jan 15, 2013 Jan 15, 2013

Copy link to clipboard

Copied

Hi,

I have spent weeks in trying to solve this, any help would be greatly appreciated.

Below is the code snippet

function eduPlay()

{

    for (var i:int=0; i<introAni.length; i++)

    {

        if (introAni == "University")

        {

            trace("University is selected");

            for (i=0; i<introAni.length; i++)

            {

                for (var k:int=0; k<eduUniMatch.length; k++)

                {

                    var matchNum:Number = findIndexInArray(eduUniMatch,eduUniMatch);

                   

                   

                    for (var j:int=0; j<eduUniMatchUrl[matchNum].length; j++)

                    {

                        if (introAni == eduUniMatch)

                        {

                            //trace("Match found at " + eduUniMatch);

                            trace("Match Num found at " + matchNum);

                            //trace("eduUnMatch length is " + eduUniMatchUrl[matchNum].length);

                            startArr.splice(matchNum,0,eduUniMatchUrl[matchNum]);

                                           

                            //startArr.split(String.fromCharCode(10));

                            trace("The value of startArr is " + eduUniMatchUrl[matchNum]);

                            trace("The value of startMainArr is " + startArr);

                            //break;

                        }

                        break;

                    }

                }

            }

        }

        if (introAni == "School")

        {

            trace("School is selected");

        }

    }

}

I want to achieve the below:

load the swf files stored in an array based on what parameter is selected in the xml file. It may be different combinations.

To explain it in short. I have 4 base arrays Introduction, Demo, Overview and Training. The user may select any combination of these like Introduction + Training or Overview + Demo or Introduction + Demo + Overview or all the four or it may be any one of these.

These files should always play in sequence like these Introduction, Demo, Overview, Training. If user selects Introduction + Demo. Intro should play first and then demo. If Demo and Training are selected Demo should come prior to Training and so on.

I am able to load files and play them as well using the above function. But if there are more then one file in an array say for example in Training it does not load and play. I tried to use the String.split to split it into different files using comma but it doesn't work. Another issue i did face is the files are not playing sequentally.

If for example Demo and Training are selected by the user Training is played first and then demo.

Would be helpful for me if someone guides me on this.

TOPICS
ActionScript

Views

481

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 15, 2013 Jan 15, 2013

As far as playing in order goes, one way you could approach it is to have an array that lists the toppics in their correct order and then use that to compare what the user selected and build another array to contain the play sequence.  You go thru the ordered array in order and see if the user-selection array contains each item.  When it does, then you add the item to the play array. 

for(var i:uint=0; i<orderedArray.length; i++){

    if(userselectionArray.indexOf(orderArray) > -1){

        playAr

...

Votes

Translate

Translate
LEGEND ,
Jan 15, 2013 Jan 15, 2013

Copy link to clipboard

Copied

As far as playing in order goes, one way you could approach it is to have an array that lists the toppics in their correct order and then use that to compare what the user selected and build another array to contain the play sequence.  You go thru the ordered array in order and see if the user-selection array contains each item.  When it does, then you add the item to the play array. 

for(var i:uint=0; i<orderedArray.length; i++){

    if(userselectionArray.indexOf(orderArray) > -1){

        playArray.push(orderArray);

    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 16, 2013 Jan 16, 2013

Copy link to clipboard

Copied

LATEST

Thanks a lot for the help. With your suggestion the newly tweaked function worked and was much shorter than the earlier one.

function eduPlay()

{

    for(var i:int=0; i<introAni.length; i++)

    {

        if(introAni == "University")

        {

            trace("University is selected");

            for(i=0; i<eduUniMatch.length; i++)

            {

                var matchNum:Number = findIndexInArray(eduUniMatch,eduUniMatch);

                if(introAni.indexOf(eduUniMatch[matchNum])>-1)

                {

                    for(var j:int=0; j<eduUniMatchUrl[matchNum].length; j++)

                    {

                    startArr.push(eduUniMatchUrl[matchNum]);

                    //trace(eduUniMatchUrl[1][0]);

                   

                    }

                }

                  

            }

        }

       

    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines