Thanks Spiros,

My real problem is the following. I'm trying to improve Modules. I found
that inject_html don't work with modules, Inject_html is processed by
compiler. To solve in an easy way I'm trying to load CSS and JS with
javascript appending to head.

When I load the module and I use a class that needs to attach some JS, I
want to run a function like "loadJavascript"

I created as well "loadCSS" (still not commited).

The real use case I'm trying is to use MaterialIconType, that was using
inject_html. I removed the inject_html directive,
then added

loadCSS('https://fonts.googleapis.com/icon?family=Material+Icons');

in the constructor

then in my real module I want just to use as always

<js:FontIcon text="{MaterialIconType.SEARCH}" material="true"/>

accesing this way does not run the constructor, so the loadCSS code does
not run :(


We have hundreds of public static vars like

public static const SEARCH:String = 'search';

So I think the current way you propose, although valid, will not be the
best here, since will means lots of lines of code.

But thanks for your suggestion

Hope others could give as well some ideas on how to solve this

thanks



El mié., 26 jun. 2019 a las 17:05, spiros (<[email protected]>) escribió:

> It is possible with static getter and seter.
>
> Maybe will help you the code below
>
> Spiros.
>
> public class Variable
>         {
>
>                 private static var _textData:String;
>
>                 public static function get textData():String
>                 {
>                         if( _textData ==null)
>                         {
>                                 initailizeVariable();
>                         }
>                         return _textData;
>                 }
>
>                 public static function set textData(value:String):void
>                 {
>                         _textData = value;
>                 }
>
>                 public static function initailizeVariable():void
>                 {
>                         _textData = "The quick brown fox jump over the
> lazy dog.";
>                 }
>
>
>                 public function Variable()
>                 {
>                 }
>         }
>
>
>
>
>
> -----Original Message-----
> From: Carlos Rovira [mailto:[email protected]]
> Sent: Wednesday, June 26, 2019 5:49 PM
> To: [email protected]
> Subject: Trying to run a function on a class that is not instantiated
>
> Hi,
>
> I need to run a function when I access a public static var in a class.
> Trying to run the function in the constructor seems not to work since
> there's no instance of that class. Do we have some way to do this?
>
> --
> Carlos Rovira
> http://about.me/carlosrovira
>
>

-- 
Carlos Rovira
http://about.me/carlosrovira

Reply via email to