Skip navigation
Currently Being Moderated

getDefinitionByName() gives error #1065

Jul 12, 2011 11:56 AM

So I have my code written like this.


var classReference:Class = getDefinitionByName("Widget") as Class;
var instance:Object = new classReference();

 

And I realize I am getting this error because I have no other instance of Widget anywhere and so it's not being compiled. Let's say I have 100 different classes that I need to use getDefinitionByName() ...Is there a way I can get around this without having to have:

 

var classReferene:Widget;

 

Thanks,

 
Replies
  • Currently Being Moderated
    Jul 12, 2011 3:14 PM   in reply to iamcootis

    Hi,

     

    having:

     

     

    package

    {

         public class Widget

         {

              public function test():void

              {

                   trace("test");

              }

         }

    }

     

     

    accessed as:

     

     

    var widgetClass:Class = flash.utils.getDefinitionByName("Widget") as Class;

    var widgetInstance:Object = new widgetClass();

    widgetInstance.test();

     

     

    you could add:

     

    -includes Widget

     

    to additional compiler options (and then everything will work ;))

    see:

    http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf 69084-7a92.html

     

    hth,

    kind regards,

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 12, 2011 5:25 PM   in reply to Peter Blazejewicz

    And to do 100 classes, reference them all in a single class and -includes

    the one class, or list them all in a -config.xml file.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 11, 2013 11:33 PM   in reply to Flex harUI

    Can you tell me how to do this? I tried  -load-config+=addonclasses.xml as a compiler argument. This is the content of addonclasses.xml:

    <?xml version="1.0"?>

    <flex-config xmlns="http://www.adobe.com/2006/flex-config">

        <compiler>

            <source-path>

                <path-element>.</path-element>

            </source-path>

        </compiler>

        <include-classes>

                  <class>ch.crealogix.satellite.addons.learningcontent.LearningCon tentFacadeAddon</class>

        </include-classes>

    </flex-config>

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 12, 2013 9:18 AM   in reply to tiefenauer83

    I think if you are compiling app.mxml and you have the file named app-config.xml in the same folder it will use it automatically.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points