You just need to declare it somewhere, its still dynamic, i.e. it may be created it may not. You don't have to actually use the declared var, your just making sure thats its available for creation.

private var declared:views.pr.ProjectView;


--------------------------------------------------------------

Stephen Downs
Addict, Tink Ltd.

e: [EMAIL PROTECTED]
t: +44 (0) 7730 838 785
w: http://www.tink.ws

--------------------------------------------------------------




On 18 Apr 2008, at 08:38, Dale Fraser wrote:


Thanks,



That kind of makes it non dynamic if I need to reference it elsewhere. Is there a way around this.



Regards

Dale Fraser

http://learncf.com

http://flexcf.com





From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Christophe Herreman
Sent: Friday, 18 April 2008 5:08 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Dynamic Instance Problem



Hi Dale,

did you reference the class somewhere in your code?
It needs to be compiled into the swf in order to instantiate it dynamically.

My personal preference is to do this with a static code block:

{
  MyClass1,
  MyClass2
}

regards,
Christophe

--
Christophe Herreman
http://www.herrodius.com
http://www.pranaframework.org

2008/4/18, Dale Fraser <[EMAIL PROTECTED]>:

Anyone tell me why this doesn't work.



var ClassName:String = 'views.pr.ProjectView';

var ClassReference:Class = getDefinitionByName(ClassName) as Class;

var instance:UIComponent = new ClassReference();

child.addChild( instance );



ReferenceError: Error #1065: Variable ProjectView is not defined.

      at global/flash.utils::getDefinitionByName()

      at Main/addTab()[C:\ Central\Flex\src\Main.mxml:86]

      at Main/treeChanged()[C:\ Central\Flex\src\Main.mxml:52]

      at Main/__menuTree_click()[C:\ Central\Flex\src\Main.mxml:138]





Regards

Dale Fraser

http://learncf.com

http://flexcf.com








--
Christophe Herreman
http://www.herrodius.com
http://www.pranaframework.org





Reply via email to