Re: [flexcoders] Dynamic Instance Problem

2008-04-18 Thread Christophe Herreman
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


RE: [flexcoders] Dynamic Instance Problem

2008-04-18 Thread Dale Fraser
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://learncf.com

 http://flexcf.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://learncf.com/ 

http://flexcf.com http://flexcf.com/ 

 

 




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

 



Re: [flexcoders] Dynamic Instance Problem

2008-04-18 Thread Stephen Downs
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








RE: [flexcoders] Dynamic Instance Problem

2008-04-18 Thread Dale Fraser
Doesn't work for my needs.

 

I need to create object instances based on XML data. The component creating
the instances isn't aware of what objects might get created. So I would need
to declare every type of object just in case. Which means it's not dynamic
at all, as soon as there is a new Object I need to modify the code to allow
for it.

 

Regards

Dale Fraser

 http://learncf.com/ http://learncf.com

 http://flexcf.com/ http://flexcf.com

 

 

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

 

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:  mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]

t: +44 (0) 7730 838 785

w:  http://www.tink.ws 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://learncf.com/ 

http://flexcf.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://learncf.com/ 

http://flexcf.com http://flexcf.com/ 

 

 




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

 

 

 



Re: [flexcoders] Dynamic Instance Problem

2008-04-18 Thread Christophe Herreman
You could also build your project with Ant and pass in a list of extra
classes to the compiler with the include-classes option. The list of extra
classes can be derived from your xml file.

I need to create object instances based on XML data. Have you checked
Prana? (www.pranaframework.org) ;-)

regards,
Christophe

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

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

Doesn't work for my needs.



 I need to create object instances based on XML data. The component
 creating the instances isn't aware of what objects might get created. So I
 would need to declare every type of object just in case. Which means it's
 not dynamic at all, as soon as there is a new Object I need to modify the
 code to allow for it.



 Regards

 Dale Fraser

 http://learncf.com

 http://flexcf.com





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



 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:flexcoders flexcoders@
 yahoogroups.com] *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





   




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


RE: [flexcoders] Dynamic Instance Problem

2008-04-18 Thread Gordon Smith
If your XML says to instantiate a Foozle, there needs to be a compiled
Foozle class somewhere. Either that class is in the main Application SWF
or it is in some SWF (probably a module SWF which works with Flex's
module-loadind APIs) that gets loaded -- possibly on demand -- by the
main SWF. If the dynamically instantiated classes can't be in the main
SWF, then you need to look into modules.

 

Gordon Smith

Adobe Flex SDK Team

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Dale Fraser
Sent: Friday, April 18, 2008 1:11 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Dynamic Instance Problem

 

Doesn't work for my needs.

 

I need to create object instances based on XML data. The component
creating the instances isn't aware of what objects might get created. So
I would need to declare every type of object just in case. Which means
it's not dynamic at all, as soon as there is a new Object I need to
modify the code to allow for it.

 

Regards

Dale Fraser

http://learncf.com http://learncf.com/ 

http://flexcf.com http://flexcf.com/ 

 

 

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

 

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] mailto:[EMAIL PROTECTED] 

t: +44 (0) 7730 838 785

w: http://www.tink.ws 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://learncf.com/ 

http://flexcf.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.herrodius.com 
http://www.pranaframework.org http://www.pranaframework.org 

2008/4/18, Dale Fraser [EMAIL PROTECTED] mailto:[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://learncf.com/ 

http://flexcf.com http://flexcf.com/ 

 

 




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

 

 

 



RE: [flexcoders] Dynamic Instance Problem

2008-04-18 Thread Rick Winscot
Dale - you are right. the more dangling class (concrete) references you have
to keep in your code to keep introspection from failing - the more your
approach looks like a problem rather than a solution. My first
recommendation is - if you have to use dangling references let them be
interfaces. This will allow you to swap out an implementation based on the
foundation of an established contract without being bound to the class name
(you can only have one class by a specific name. but you can have many
classes that implement your interface). If you require more flexibility.
your only other option is to acquire a reference to your new class but treat
and cast it as an Object and not a typed class. You can perform any
operation you need without a contract. however - the less you know about an
externally loaded asset and the potential implementation the greater your
risk of causing runtime errors.

 

Rick Winscot

 

 

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Dale Fraser
Sent: Friday, April 18, 2008 3:38 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Dynamic Instance Problem

 

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://learncf.com/ 

http://flexcf.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://learncf.com/ 

http://flexcf.com http://flexcf.com/ 

 

 




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

 

image001.jpgimage002.jpg

RE: [flexcoders] Dynamic Instance Problem

2008-04-18 Thread Rick Winscot
Having a dangling concrete class reference is really a cheat. due to the
nature of Flex/ActionScript class hierarchies. Perhaps a better term in lieu
of 'dynamic' would be 'unknown.' This is where interfaces make a great deal
of sense and provide a no-nonsense way of saying. I don't know what I'm
going to load here but generally this is what I want it to do and this is
minimally what it should look like.  Introspection can quickly become a
chicken and egg scenario when dealing with unknowns - which is why the
dangling concrete class reference has been embraced by so many (typically
those who haven't been doing this with C, C++, etc). I agree with Dale. the
dangling reference isn't the solution to the 'unknown' problem. The first
step would be looking towards interfaces --- the next would be using the
ActionScript Object type for complete freedom. 

 

Rick Winscot

 

 

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Stephen Downs
Sent: Friday, April 18, 2008 3:48 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Dynamic Instance Problem

 

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:  mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]

t: +44 (0) 7730 838 785

w:  http://www.tink.ws 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://learncf.com/ 

http://flexcf.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://learncf.com/ 

http://flexcf.com http://flexcf.com/ 

 

 




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

 

 

 

image001.jpgimage002.jpg