Hi, I’m having trouble getting to the bottom of this error. The debugger says my class is undefined. Wonder if you might have some ideas, I cannot manipulate the properties in side the Ball class I have created in my main document class.
May be a scope error of some kind or a problem with my Ball class declaration.
/* Main Document Class*/
package {
import flash.geom.ColorTransform;
import flash.display.MovieClip;
import fl.motion.Color;
import flash.display.*;
import flash.events.Event;
//-------------------------------------------------------------------
//-- This class performs the animation in the main canvas. ----------
//-------------------------------------------------------------------
public dynamic class Main extends MovieClip {
private var max,num,cur,mxm,mym:int = 100; // current ball and mouse x y & number of balls
//private var Ball[] ball = new Ball[max]; // array of balls for interaction purposes
private var massArray:Array = new Array();
//Ticker tick;
private var clearAll:Boolean;
// The following are some "physical" properties. Each property
// has a value and a control. The values are updated once per
// animation loop
public var g,mg,f,r:Number;
public var trc,col,mu,wr,sm,fi:Boolean;
public var xsize,ysize:int;
//Scrollbar grav,mgrav,fric,rest;
//Checkbox trace,collide,mush,wrap,smooth,filled;
[COLOR="RoyalBlue"]private var mass1,mass2,mass3:Ball; // a few balls just for testing[/COLOR]
public var colorYellow:Color=new Color();
public function Main():void {
var myMC:MovieClip = new MovieClip();
addChild(myMC);
var _stage:Stage=myMC.stage;
var starBackground:Stars = new Stars(_stage);
//Add three balls
[COLOR="royalblue"] var mass1:Ball = new Ball(100,12,colorYellow,100,250,4,2,_stage,myMC);
mass1.name = "m1";
_stage.addChild(mass1);[/COLOR]
var mass2:Ball = new Ball(100,15,colorYellow,325,225,-5.45,1,_stage,myMC);
mass2.name = "m2";
var mass3:Ball = new Ball(100,22,colorYellow,400,50,0.45,1,_stage,myMC);
mass3.name = "m3";
addEventListener(Event.ADDED_TO_STAGE, moveobj);
}
public function moveobj(event:Event) {
//error Error #1010: A term is undefined and has no properties
[COLOR="Red"]**mass1._x+=1**; **// error points to here**[/COLOR]
}//end function
}//class
}//package