flash actionscript:
This program works with a rotating image with 3 pictures. q) How can I use an array for declaring this variable for 'X' number of these var this["mLoad"+2]:MovieClipLoader= new MovieClipLoader(); q0 Is there an easier way to load an 'X' number of pictures like i have done? //import mx.controls.ComboBox; var aval:Array= new Array(); aval.push("50img2.jpg"); aval.push("8img1.png"); aval.push("98img1.jpg"); var txt2:String; var txt11:String; var mLoad:MovieClipLoader = new MovieClipLoader(); var mLoad2:MovieClipLoader = new MovieClipLoader(); var mLoad3:MovieClipLoader = new MovieClipLoader(); this.createEmptyMovieClip("mc0",this.getNextHighestDepth()); this.createEmptyMovieClip("mc1",this.getNextHighestDepth()); this.createEmptyMovieClip("mc2",this.getNextHighestDepth()); var tum:Number; var swap:Number; //var i:Number; //var j:Number; i=0; j=1; ii=0; jj=1; swap=0; loadpics(ii,jj); //trace(this["mc"+2]._x); //trace(88); tum=setInterval(fade,50,i,j); function fade(i:Number,j:Number):Void { if (_root["mc"+i]._parent._x >=0) _root["mc"+i]._alpha -=1; if (_root["mc"+j]._parent._x <=100) _root["mc"+j]._alpha+=1; if (_root["mc"+j]._alpha >=100) { trace(i+" "+j); _root["mc"+j]._alpha =100; _root["mc"+i]._alpha =0; //loadpics(1,2); flicker i++; j++; if (j==3) { j=0; } if (i==3) { i=0; } clearInterval(tum); tum=setInterval(fade,50,i,j); } } function loadpics(ii:Number,jj:Number):Void { mLoad.loadClip(aval[0],mc0); mc0._alpha=100; mLoad2.loadClip(aval[1],mc1); mc1._alpha=0; mLoad3.loadClip(aval[2],mc2); mc2._alpha=0; //trace(this["mc"+2]._x); //trace(88); }
: var aval:Array = new Array(); aval.push("50img2.jpg"); aval.push("8img1.png"); aval.push("98img1.jpg"); lo = new Object(); lo.onLoadInit = function(target) { // initiate your fade loop for target }; for (var i = 1; i<aval.length; i++) { this["mLoad"+i] = new MovieClipLoader(); this.createEmptyMovieClip("mc"+i, this.getNextHighestDepth()); this["mLoad"+i].addListener(lo); this["mLoad"+i].loadClip(aval[i], this["mc"+i]); }
Hi Thanks for the reply. I don't really understand the need for the lo object. If you do this then every MC has a timer which is not what i want. So what goes in that function and why do I need it? lo = new Object(); lo.onLoadInit = function(target) { // initiate your fade loop for target tum=setInterval(fade,50,0,1); //calls for every }; for (var i = 1; i<aval.length; i++) { this["mLoad"+i] = new MovieClipLoader(); this.createEmptyMovieClip("mc"+i, this.getNextHighestDepth()); this["mLoad"+i].addListener(lo); this["mLoad"+i].loadClip(aval[i], this["mc"+i]); }
you need it to determine when your images have completed loading and are ready to fade. but if you don't care whether that fade loop is doing anything visible to your users, you can elimate every line of code that contains lo.
Don't see what you're looking for? Try a search.
|