Ok, here is my question: I have two classes a main and one controlling a cloud graphic going on the stage. In the main class I am creating an instance of the cloud, adding it to the stage with an array and with a for loop I am setting the x speed (vx). I have noticed that if I set the vx in the cloud class and reference it directly then it does not work (clouds are drawn for a millisecond then a blank movie). I have to initialize the cloud.vx value in the main class to get it to work. Why can I not just pull the vx value from the cloud class without setting it to a value in the main class?
Main class
package
{
import flash.display.MovieClip;
import flash.events.*;
import parts.Cloud_mc;
public class Main extends MovieClip
{
public var cArray:Array;
public var cloudsTotal:uint = 10;
public var vx:Number = 2;
public function Main()
{
init();
}
public function init()
{
cArray = new Array()
for(var i = 0; i < cloudsTotal; i++)
{
var cloud:MovieClip = new Cloud_mc();
cloud.x = Math.random() * stage.stageWidth;
cloud.y = Math.random() * stage.stageHeight;
//cloud.vx = Math.random(); If I initialize the code here it works
addChild(cloud);
cArray.push(cloud);
}
stage.addEventListener(Event.ENTER_FRAME, eFrame);
}
public function eFrame(event:Event):void
{
for(var i = 0; i < cArray.length; i++)
{
var cloud:Cloud_mc = cArray*;
[COLOR="Red"]cloud.x += cloud.vx;[/COLOR]
}
}
}
}
Cloud class
package parts
{
import flash.display.MovieClip;
public class Cloud_mc extends MovieClip
{
public var vx:Number = 4;
public function Cloud_mc(a:Number, w:Number, h:Number)
{
}
}
}