[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

Arrays and For Loops

Hi Folks,

I have a videowindow that plays the video. Based on the current frame number i need to perform certain actions. I

I have the following if statements that I need to convert into a array for faster processing. What is the best way to do it

    if ((_parent.video._currentframe > 1135) && (_parent.video._currentframe < 1260)) {
        _root.QA_mc._visible = true;
        _root.QA_mc.gotoAndStop(2);
    }

    if ((_parent.video._currentframe > 1581) && (_parent.video._currentframe < 1699)) {
        _root.QA_mc._visible = true;
        _root.QA_mc.gotoAndStop(3);
    }

    if ((_parent.video._currentframe > 700) && (_parent.video._currentframe < 800)) {
        _root.popup.gotoAndPlay("gettingThere");
    }

Thanks

RG
0
rgarimella
Asked:
rgarimella
  • 2
1 Solution
 
negatyveCommented:
If this is all the code, I don't think you should use an array, as I cannot see any pattern in that script (no pattern for frame numbers, no pattern for actions - sometimes frame numbers, sometimes labels, sometimes change QA_, sometimes popup..)
0
 
rgarimellaAuthor Commented:
Actualy I have more than displayed here. I was just putting a sample

0
 
negatyveCommented:
Well, actually you could do something like this:

var choices = [{min:1135, max:1260, frame:2}, {min:1581, max:1699, frame:3}];
var found = false;
for(var i = 0; i < choices.length; i++){
      var cf = _parent.video._currentframe;
      var co = choices[i];
      if(cf > co.min && cf < co.max){
            _root.QA_mc._visible = true;
            _root.QA_mc.gotoAndStop(co.frame);
            found = true;
            break;
      }
}
if(!found){
      _root.popup.gotoAndPlay("gettingThere");
}
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now