Posts

Showing posts with the label actionscript-3

Trying to access another MovieClip on frame 2 of a movieclip on main timeline

Trying to access another MovieClip on frame 2 of a movieclip on main timeline I am working with nesting of movieclips. I am trying to access another movieclip in frame 2 of main movieclip on stage. => test2 movieclip is present on frame2 of test movieclip. I am getting this error because of accessing test2 variable.. TypeError: Error #1009: Cannot access a property or method of a null object reference. at Untitled_fla::MainTimeline/Access() at Untitled_fla::MainTimeline/Untitled_fla::frame1() Any alternate method to access test2 movieclip on frame2 of main movieclip? My Code is : var test1:MovieClip; var test2:MovieClip; test.stop(); function Start(){ //test.addChild(test1); //Test1 = new test1(); //Test2 = new test2(); trace(test.numChildren); test1 = MovieClip(test.getChildByName("test1")); test.gotoAndStop(2); test2 = MovieClip(test.getChildByName("test2")); } function Access(color:String){ var r:RegExp=new RegExp(/#/);...

AS3: Adding function to population loop

AS3: Adding function to population loop Basically I have 2 movieclip objects with some code, currently just to trace them. The blue circles when clicked will say 'Blue' and the red ones when clicked will say 'Red'. This works fine in theory until I add a population loop, which adds more of them. Then only 1 of each colour correctly works, the rest are just 'mock' circles. I wish for each circle to tell me their colour. This is my code for the .fla: import flash.events.MouseEvent; BlueBall.addEventListener(MouseEvent.CLICK, fun1) function fun1(e:MouseEvent){ trace("Blue!"); } RedBall.addEventListener(MouseEvent.CLICK, fun2) function fun2(e:MouseEvent){ trace("Red!"); } and this is the population loop in an .as file: private function PopulateCircles():void { for (var i:int=0; i < 10; i++) { var blueCircle:BlueCircle = new BlueCircle(); this.addChild(blueCircle); var redCircle:RedCircle = new RedCircle(...