[flexcoders] Re: Create mxml custom component in a actionscript event handler

2009-04-15 Thread raja_s_patil
Thanks Tracy Spratt,
>
> The compiler compiles the function regardless of whether it is ever called,
> If you reference a class that it cannot find it will error.
> 
>  
> 
> No, if you are using normal classes, then you must have a reference to that
> class in order for it to be linked in at compile.  This is one of the
> problems the Modules are intended to address.  Note, the reference can
> simply be a variable declaration typed as the class.

Well I Found the solution..
Flex compiler's artificial intelligence doesn't link
all the imported classes unless those are refered somewhere
in the code. So its necessary to refer the class somewhere
in the application. So what i did was I declared a dummy variable

var frm1:Form1 = null;
var frm2:Form2 = null;

and it worked like a magic now dynamic creation works like a charm.


Please refer to this URL
http://jwopitz.wordpress.com/2008/02/21/getdefinitionbyname-trick/

its claimed that this is a elegant way of achieving same result
but I could not understand it properly. If possible can u 
elaborate the technique he has used in ur next post.

> 
> But I am still more confused about your problem.  Let's try again. Can you
> instantiate Form1 if you wanted to? 
> 

I think u might have got exact problem from above mentioned 
text. If possible please comment on what I have done
whether its a best practice or not and suggest better alternative.

Thanks for interest shown and time spent on me.

I feel that I have got another good friend now.

Best regards


RAJA




RE: [flexcoders] Re: Create mxml custom component in a actionscript event handler

2009-04-14 Thread Tracy Spratt
The compiler compiles the function regardless of whether it is ever called,
If you reference a class that it cannot find it will error.

 

No, if you are using normal classes, then you must have a reference to that
class in order for it to be linked in at compile.  This is one of the
problems the Modules are intended to address.  Note, the reference can
simply be a variable declaration typed as the class.

 

But I am still more confused about your problem.  Let's try again. Can you
instantiate Form1 if you wanted to? 

 

Tracy Spratt,

Lariat Services, development services available

  _  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of raja_s_patil
Sent: Wednesday, April 15, 2009 12:24 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Create mxml custom component in a actionscript
event handler

 






Thanks Tracy Spratt,
>
> Ok, what happens if you just try to instantiate a Form1? If the code is
not
> finding this class then you certainly can't proceed.
> 

As I have stated in my earlier posts commenting
the onItemClick function the Form1 can not be instantiated

if I remove comment on onItemClick function Form1 gets
instantiated

Please refer my First Post in this Thread.

I am not understanding what difference it makes
when I comment out a unused function.

Well to best my guess when Form1 is referred explicitly in
onItemClick function the mxml class Form1 is being linked
but when I comment onItemClick function Form1 Class is
not being linked. 

Is there any way to Link this Form1 in application so that 
its available for dynamic Instantiation i.e. without having 
any explicit reference in main application.

Thanks and Best Regards

Raja 





[flexcoders] Re: Create mxml custom component in a actionscript event handler

2009-04-14 Thread raja_s_patil
Thanks Tracy Spratt,
>
> Ok, what happens if you just try to instantiate a Form1?  If the code is not
> finding this class then you certainly can't proceed.
> 

As I have stated in my earlier posts commenting
the onItemClick function the Form1 can not be instantiated

if I remove comment on onItemClick function Form1 gets
instantiated

Please refer my First Post in this Thread.

I am not understanding what difference it makes
when I comment out a unused function.

Well to best my guess when Form1 is referred explicitly in
onItemClick function the mxml class Form1 is being linked
but when I comment onItemClick function Form1 Class is
not being linked. 

Is there any way to Link this Form1 in application so that 
its available for dynamic Instantiation i.e. without having 
any explicit reference in main application.

Thanks and Best Regards

Raja  




RE: [flexcoders] Re: Create mxml custom component in a actionscript event handler

2009-04-14 Thread Tracy Spratt
Ok, what happens if you just try to instantiate a Form1?  If the code is not
finding this class then you certainly can't proceed.

 

 

Tracy Spratt,

Lariat Services, development services available

  _  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of raja_s_patil
Sent: Tuesday, April 14, 2009 8:52 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Create mxml custom component in a actionscript
event handler

 






Thanks Tracy Spratt
>
> Have you imported Form1 and Form2?
> 

I tried import Form1; but no effect.

How a import statement if Form1 and Form2 are in same 
source directory that of application ?

The output directory is bin-debug within the source directory.
Project directory is same as source directory.

BTW if comments are removed how the code works, 
what happens when comments are put 
can u shed some light on these point ?

Thanks and Best Regards

Raja





[flexcoders] Re: Create mxml custom component in a actionscript event handler

2009-04-14 Thread raja_s_patil
Thanks Tracy Spratt
>
> Have you imported Form1 and Form2?
> 

I tried import Form1; but no effect.

How a import statement if Form1 and Form2 are in same 
source directory that of application ?

The output directory is bin-debug within the source directory.
Project directory is same as source directory.

BTW if comments are removed how the code works, 
what happens when comments are put 
can u shed some light on these point ?

Thanks and Best Regards

Raja





RE: [flexcoders] Re: Create mxml custom component in a actionscript event handler

2009-04-14 Thread Tracy Spratt
Have you imported Form1 and Form2?

 

Tracy Spratt,

Lariat Services, development services available

  _  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of raja_s_patil
Sent: Tuesday, April 14, 2009 1:47 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Create mxml custom component in a actionscript
event handler

 






thanks Tracy Spratt
>
> What error?
> 

ReferenceError: Error #1065: Variable Form1 is not defined.
at global/flash.utils::getDefinitionByName()
at MyFirst/menuSelected()[I:\Flex\RSP_TESTS\MyFirst\MyFirst.mxml:31]
at
MyFirst/___MyFirst_MenuTree1_menuSelected()[I:\Flex\RSP_TESTS\MyFirst\MyFirs
t.mxml:42]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at
mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\
framework\src\mx\core\UIComponent.as:9298]
at MenuTree/menuSelected()[I:\Flex\RSP_TESTS\MyFirst\MenuTree.mxml:52]
at
MenuTree/___MenuTree_Tree1_itemClick()[I:\Flex\RSP_TESTS\MyFirst\MenuTree.mx
ml:7]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at
mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\
framework\src\mx\core\UIComponent.as:9298]
at
mx.controls.listClasses::ListBase/mouseClickHandler()[C:\autobuild\3.2.0\fra
meworks\projects\framework\src\mx\controls\listClasses\ListBase.as:9040]
at
mx.controls::Tree/mouseClickHandler()[C:\autobuild\3.2.0\frameworks\projects
\framework\src\mx\controls\Tree.as:2922]

This is what a popup window in browser has printed
The browser is firefox, Flex builder 3 and the
application is a evaluation pilot one nothing special in it
no database connectivity etc. etc. It contains two forms,
one custom mxml component with custom event, one custom event class and a
general utility functions class.

Thanks and best regards

Raja





[flexcoders] Re: Create mxml custom component in a actionscript event handler

2009-04-14 Thread raja_s_patil
thanks Tracy Spratt
>
> What error?
> 

ReferenceError: Error #1065: Variable Form1 is not defined.
at global/flash.utils::getDefinitionByName()
at MyFirst/menuSelected()[I:\Flex\RSP_TESTS\MyFirst\MyFirst.mxml:31]
at 
MyFirst/___MyFirst_MenuTree1_menuSelected()[I:\Flex\RSP_TESTS\MyFirst\MyFirst.mxml:42]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at 
mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298]
at MenuTree/menuSelected()[I:\Flex\RSP_TESTS\MyFirst\MenuTree.mxml:52]
at 
MenuTree/___MenuTree_Tree1_itemClick()[I:\Flex\RSP_TESTS\MyFirst\MenuTree.mxml:7]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at 
mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298]
at 
mx.controls.listClasses::ListBase/mouseClickHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:9040]
at 
mx.controls::Tree/mouseClickHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\controls\Tree.as:2922]

This is what a popup window in browser has printed
The browser is firefox, Flex builder 3 and the
application is a evaluation pilot one nothing special in it
no database connectivity etc. etc. It contains two forms,
one custom mxml component with custom event, one custom event class and a 
general utility functions class.

Thanks and best regards

Raja