Arrays and For Loops

Posted on 2004-11-22
Last Modified: 2010-04-03
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 (( > 1135) && ( < 1260)) {
        _root.QA_mc._visible = true;

    if (( > 1581) && ( < 1699)) {
        _root.QA_mc._visible = true;

    if (( > 700) && ( < 800)) {


Question by:rgarimella
    LVL 27

    Expert Comment

    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..)

    Author Comment

    Actualy I have more than displayed here. I was just putting a sample

    LVL 27

    Accepted Solution

    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 =;
          var co = choices[i];
          if(cf > co.min && cf < co.max){
                _root.QA_mc._visible = true;
                found = true;

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
    The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
    The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now