actionscript 3 - A3 Arrays of movieClips -


[as3.0] i'm working on graduation diploma , have problem managing movieclips same instance name..sort of. i'm creating array of objects class arrays in frame 1:

package  {     import flash.display.movieclip;      public class createfractionbuilding     {         public function createfractionbuilding(_fractionbuildingmovieclip:movieclip, _fractionbuildinglevel:number,_fractionbuildingcost:number, _fractionbuildingframe:number)         {             fractionbuildinglevel = _fractionbuildinglevel;             fractionbuildingcost = _fractionbuildingcost;             fractionbuildingmovieclip = _fractionbuildingmovieclip             fractionbuildingframe = -fractionbuildingframe         }          public var fractionbuildinglevel:number,fractionbuildingcost:number,fractionbuildingframe:number;         public var fractionbuildingmovieclip:movieclip     } } 

on main timeline i'm refering class creating array of objects:

var allhumanbuildingslist:array = new array();  var humancapitolbuildingproperties:createfractionbuilding = new createfractionbuilding(humancapitol_mc,1,1000,1); var humancastlebuildingproperties:createfractionbuilding = new createfractionbuilding(humancastle_mc,2,1000,1);  allhumanbuildingslist.push(humancapitolbuildingproperties); allhumanbuildingslist.push(humancastlebuildingproperties); 

for work have have movieclip called "humancapitol_mc" or "humancastle_mc" in frame (1).

but in frame (2) want refer movieclip such function:

function humanbuildinglevelcheck() {     (var a:number = 0; < allhumanbuildingslist.length; a++)     {         trace (string(allhumanbuildingslist[a].fractionbuildingmovieclip))         if (allhumanbuildingslist[a].fractionbuildinglevel == 2){             allhumanbuildingslist[a].fractionbuildingmovieclip.gotoandstop(3)         } else if (allhumanbuildingslist[a].fractionbuildinglevel == 1){             allhumanbuildingslist[a].fractionbuildingmovieclip.gotoandstop(2)         }     } } humanbuildinglevelcheck() 

(each movieclip on first frame blank, on second 1 picture, on third different one)

everything works, when array creation code in frame two, won't work way want: first create variables , objects , change it's values dynamically. have idea, how work?

make global. if 1 variable declared in keyframe 1, can't see in keyframe 2 if declare in 1 layer has 1 keyframe visible anywhere within timeline.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -