views:

126

answers:

0

Hi there!

What is the best practice for updating an object at Event.ENTER_FRAME?

here's the code:

addEventListener(Event.ENTER_FRAME, enter_frame);


protected function enter_frame(event:Event):void
{ 
 //update the object in the exernal class
 Extrn.updaterMethode(anObject);

 // some logic
 if(foo==bar)
 {
  // get a property from the latest external object
  Alert.show(Extrn.latestObject.somthg);
 }
}


public class Extrn
{
 static public var latestObject:Object = new Object();

 public static function updaterMethode(array:Object):void
 {
  latestObject.somthg = "something dynamic";
 }
}

I'm listening to the flex application by enter_frame then call an external class method that updates an object in that class so that I can access this object later.

is this a good way to do it? I mean wont that create thousands of objects and reduce memory and cause unwanted behavior because I'm creating objects at frame interval?

thanx for any tips!