Can I create an instance of a class from AS3 just knowing his name?

Create instances of classes dynamically by name. To do this following code can be used: //cc() is called upon creationComplete private var forCompiler:FlagFrance; //REQUIRED! (but otherwise not used) private function cc():void { var obj:Object = createInstance(“flash.display.Sprite”); } public function createInstance(className:String):Object { var myClass:Class = getDefinitionByName(className) as Class; var instance:Object = new myClass(); return instance; } … Read more

Static Actionscript code analysis possibilities

Update Nov 2018: It would appear that Structure101 (new download page) no longer has an ActionScript variant. Original answer, links outdated: Download Structure101g and select the Actionscript flavor after installing the software. I’ve confirmed that it is able to map out class level and even function call dependencies in Flex/AS3 projects, and generate a visual … Read more

Using ‘File’ to save scene object locations to rebuild later in AS3

You are trying to write a DisplayObject into the file directly, this is prevented by Flash engine due to the way Flash handles default serialization of any object. In order to save a DisplayObject into the external resource, you need to employ IExternalizable on that object’s class and any class of objects you will plan … Read more

How to pass arguments into event listener function in flex/actionscript?

A function called by a listener can only have one argument, which is the event triggering it. listener:Function — The listener function that processes the event. This function must accept an Event object as its only parameter and must return nothing, as this example shows: function(evt:Event):void Source You can get around this by having the … Read more

To pass a parameter to event listener in AS3 the simple way… does it exist?

Out of the box: it only takes 2 extra lines of elegant code to solve this ancient puzzle. stage.addEventListener(MouseEvent.CLICK, onClick(true, 123, 4.56, “string”)); function onClick(b:Boolean, i:int, n:Number, s:String):Function { return function(e:MouseEvent):void { trace(“Received ” + b + “, ” + i + “, ” + n + ” and ” + s + “.”); }; … Read more

Calculate Bounding box coordinates from a rotated rectangle

Transform the coordinates of all four corners Find the smallest of all four x’s as min_x Find the largest of all four x’s and call it max_x Ditto with the y’s Your bounding box is (min_x,min_y), (min_x,max_y), (max_x,max_y), (max_x,min_y) AFAIK, there isn’t any royal road that will get you there much faster. If you are … Read more