# Sequence class

**URL:** <https://forum.kirupa.com/t/sequence-class/228891>\
**Category:** Uncategorized\
**Created:** [June 12, 2007, 9:56am UTC](https://forum.kirupa.com/t/sequence-class/228891 "2007-06-12T09:56:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sasxa](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sasxa](https://forum.kirupa.com/u/sasxa)\
**Post date:** [June 12, 2007, 9:56am UTC](https://forum.kirupa.com/t/sequence-class/228891/1 "2007-06-12T09:56:31Z")

</div>

I’m trying to create sequence class for my application. My goal is- I’m loading bunch of images (say 15) and I want to display them in 3 sprites (for example red, green & blue). also I want to sort my images as they load and display them in my R/G/B sprites based on some property. I want to create sequence class that will hold my images when they load and when I ask I want it to return next or previous image. but, let’s say I don’t really know what I’m loading, and still want to do what I described… lol  
anyway here’s what I made so far. I’m having problems with constructor. I guess I’m not understanding how some things really work.

```auto

package classes.common.util {
    
    import flash.utils.Dictionary;

    public class Sequence extends Dictionary {
        private static var sequenceList:Array = new Array();
        
        private var sequenceName:String;
        public function Sequence(object:*) {
            super();
            var items:Array = new Array();
            sequenceName = /*Public.settings[object]..@sprite*/;
            this[sequenceName] = items;
            sequenceList.push(sequenceName);
        }
        private static var currentObject:*;
        public static function sort(object:*):void {
            currentObject = object;
            var sequenceExist:Boolean = Sequence.sequenceList.some(checkName);
            
            if (sequenceExist) {
                Sequence[/*Public.settings[object]..@sprite*/].push(object);
            } else {
                var newSequence:Sequence = new Sequence(object);
                Sequence[/*Public.settings[object]..@sprite*/].push(object);
            }
        }
        private static function checkName(element:*):Boolean {
            return (element == /*Public.settings[currentObject]..@sprite*/);
        }
        // some methods
    }
}

```

…just ignore things I commented, you can put _ **object.parent.name** _ instead… Whole point of this is to make a class and don’t care about what it does… I just want to take my object call _ **sort** _ method when it loads and when I’m done with it I’ll just call _ **getNext** _ method (deleted from code above) and use next image…

```auto

// onLoadComplete handler
function onLoadComplete(event:Event):void {
  var image:Loader = event.currentTarget.loader;
  Sequence.sort(image);
//....
// animate image
  image = Sequence.getNext(image);
}

```

if I understand corectly this is what’s my constructor suppose to do:

```auto

        public function Sequence(object:*) {
// create new instance of class as Dictionary object
            super();
// declare new array
            var items:Array = new Array();
// assign value to String variable
            sequenceName = /*Public.settings[object]..@sprite*/;
// reference that String variable in instance I created with array
            this[sequenceName] = items;
// assign value to another String variable
            sequenceList.push(sequenceName);
        }

```

but I’m obviously wrong in some steps…
