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.