[AS2] - onEnterFrame + movieClips problem

Hey guys. I have a really strange problem and for the life of me I cannot figure it out. So I’m hoping you guys have some insight.

A quick rundown of the code is I am creating movie clips that I then am trying to scroll across the screen as an infinite horizontal scroller.

Here is the problem. I am able to create the effect I want using text fields, but when using movie clips and the EXACT code, it doesn’t do anything.

Here is the code: (sorry kinda long)


function intro(){
    var main = intro_xml.firstChild.childNodes;    
    var len = main.length;
    
    var my_array:Array = new Array();
    
    var my_loader:MovieClipLoader = new MovieClipLoader();        
    var my_listener:Object = new Object();
    
    //loader_mc._alpha = 0;
    var space = 0;    
    
    my_loader.addListener(my_listener);
    my_listener.onLoadInit = function(target:MovieClip){
        //trace(target);
    };
    
    for(i=0; i<len; i++){
        **//var my_mc = loader_mc.createEmptyMovieClip("test"+i, loader_mc.getNextHighestDepth()); //DOES NOT WORK
        //var my_mc = _root.createTextField("test"+i, this.getNextHighestDepth(), 100, 100, 100, 100); //WORKS PERFECT
        //my_mc.text = "TEST"
        
        // set picture
        //my_loader.loadClip(main*.attributes.url, my_mc);    **    
        
        // set start, trigger and final positions based on this field's width
        my_mc.finalPos = 0 - 490 - space;
        my_mc.triggerPos = Stage.width - 490;
        my_mc.startPos = Stage.width + (space * 2);
        
        // set init position
        my_mc._y = 225;
        my_mc._x = my_mc.startPos;
        
        // start out not ticking
        my_mc.tick = false;
                
        // function to start the ticker for this textfield
        my_mc.run = function(){
            this._x = this.startPos;
            this.tick = true;
        };
        
        // ticker function for this textfield
        my_mc.doTick = function(){
            if(this.tick == true){
                this._x = this._x - 3;
            };
        };
        
        // trigger for next textfield's ticker starter function
        my_mc.trig = function(){
            if(this._x <= this.triggerPos && this._x > this.triggerPos - 3){
                this.nextMc.run();
            };
        };
        
        // stop this field's ticker and move it back to start position
        my_mc.fin = function(){
            if(this._x <= this.finalPos){
                this.tick = false;
            };
        };        
        my_array* = my_mc;
    };
    
    // setup the next textfields
    for(i=0; i<len; i++){
        my_array*.nextMc = my_array[(i + 1) % len];
    };
    
    // start it up
    my_array[0].run();
    onEnterFrame = function(){
        for(i=0; i<len; i++){
            my_array*.doTick();
            my_array*.trig();
            my_array*.fin();
        };
    };
};

Ok, if you notice at the top(bolded, right after the start of the first [for loop])I have commented out the createEmptyMovieClip, and replaced it with a createTextField with the same name as the movie clip (my_mc). When I do this it works perfect. If I comment out the createTextField, and use the createEmptyMovieClip, again same name as the text field, nothin’…

Please if anyone has any insight. I have been trying to figure this one out for a few days now and am at a complete loss.

Thanks.

looks like the entire scrolling works on whatever “this” is:

so, shouldn’t it be:


//instead of these:
//var my_mc = loader_mc.createEmptyMovieClip("test"+i, loader_mc.getNextHighestDepth()); //DOES NOT WORK
//var my_mc = _root.createTextField("test"+i, this.getNextHighestDepth(), 100, 100, 100, 100); //WORKS PERFECT
//my_mc.text = "TEST"

//something like this?
var my_mc = this.createEmptyMovieClip("test"+i, this.getNextHighestDepth()); 

Well “this” in that instance would be “_root”.

And doing that still produces the same problem. It’s loading all of the images off the screen but not running any of the functions in the onEnterFrame.

But when I use a text field it works fine…


var my_mc = _root.createTextField("test"+i, this.getNextHighestDepth(), 100, 100, 100, 100);
my_mc.text = "TEST"

This works exactly the way I am wanting it to, except, I need it to work on movie clips rather than text fields. And in this instance I could use; _root, this, or whatever I want to create the text field and it will work.

Using:

var my_mc = loader_mc.createEmptyMovieClip(“test”+i, loader_mc.getNextHighestDepth());
my_loader.loadClip(main*.attributes.url, my_mc);

Creates all of the movie clips, loads them all fine (off screen) but will not move them across the screen like with the text fields. And it produces the same result whether I use; _root, this, or loader_mc, or whatever.

So the only difference is that with text fields its running all of the functions at the bottom in the onEnterFrame/for loop group. Where as with movie clips it is not, and thats where I’m stuck.

No one has any ideas about this one? or a possible work around?

I would really appreciate if anyone would be able to shed some light on this.

I still haven’t been able to figure this one out if anyone has some insight.

Is there some property of movieclips that doesn’t allow them to be manipulated in this way, yet text fields are able to be manipulated?