Can I construct an Object without knowing the class in ActionScript 2? -
In AS2, I can certainly do this:
var example = new MyClass ()
;
But is there a way to do something like that?
var constructor = MyClass; Var example = new constructor (); It is possible by calling "new" on the example of a class object in AS3, but I am not able to understand how to get this syntax, working in AS2. .
You can do this:
First of all, you have to declare class This is included in the SDF
var: YOUR_CLASS;
And then you can find an example on this:
var example = new ["directory. Subdirectory.YOUR_CLASS"] ();
Edit:
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Mx: application xmlns: mx = "http://www.adobe.com/2006/mxml" layout = "vertical" xmlns: at = "at.controls. *" CreationComplete = "init ()" & gt; & Lt; Mx: script & gt; & Lt ;! [CDATA [import mx.rpc.remoting.mxml.RemoteObject; Private function init (): zero {var obj: object = ObjectLoader.getInstanceOf (RemoteObject); }] & Gt; & Lt; / Mx: script & gt; & Lt; / Mx: Applications & gt; ObjectListoder: package {public class objectloader {public function object placeholder} {} public static function getInstanceOf (CL: class): object {new return cl; }}
This is a new example. I am making an example of RemoteObject}
Comments
Post a Comment