SecretUI

SecretUI (https://www.secretui.com/forums/index.php)
-   Tutorials & Other Helpful Info (https://www.secretui.com/forums/forumdisplay.php?f=153)
-   -   [CODE] Registering a Class to Document Root. (https://www.secretui.com/forums/showthread.php?t=56)

sammichofdoom 08-03-2012 11:44 AM

[CODE] Registering a Class to Document Root.
 
In order to register a class with the root of a flash document. On frame one of your fla add some actionscript. Typically game files have a #include here. Instead do something like this:

Code:

import com.sammichofdoom.lib.RootClass.RootClass;
import com.sammichofdoom.ExampleWindow.ExampleWindow;

RootClass.Register(this, ExampleWindow);

RootClass:
Code:

/**
 * RootClass is a simple helper class to register a class to the root of a movieclip.
 * @author Sammiches
 *
 * Example:
 *
 * import lib.RootClass.RootClass;
 * import src.ExampleWindow.ExampleWindowBase;
 *
 * RootClass.Register(this, ExampleWindowBase);
 */
class com.sammichofdoom.lib.RootClass.RootClass
{
        /*
        * Register
        *
        * Register applies the ctor of the supplied class to the root of the supplied movie clip.
        *
        * @param pMovieClip:MovieClip - root of the movieclip, typically "this".
        * @param pObjClass:Object -  class you wish to register to supplied movieclip.
        */
        public static function Register(pMovieClip:MovieClip, pObjClass):Void
        {
                pMovieClip.__proto__ = Function(pObjClass).prototype;
               
                Function(pObjClass).apply(pMovieClip, null);
        }
}



All times are GMT -6. The time now is 09:11 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2020 MMOUI