heh well, after coming down from about 9 cups of coffee yesterday
(recommend folks not do that, you're brain becomes scattered)

it hit me this morning that I'm going about it wrong. I'm using XML like this

<mx:Model id="configXML" source="path/myconfig.xml"/>

I'm then parsing that and what not feeding in nodes into actual
classes and all that sort of thing.

It occured to me "why". In that if each element within my config.xml
is supposed to represent something, then why not simply put that
something right then and there..

eg:
<view-pod name="blah" settingxyz="abc"/> etc..

could be:
<SynergyFlex:viewpod name="blah" settingxyz="abc"/> etc

And basically

<mx:Model id="configXML" source="path/myconfig.xml"/>

is now

<config:MyApp/>

That way any classes i need and what not all ok, and none of this
custom-runt-time-style-compiler crap.

Can anyone see any flaws in that approach? Otherwise i'll go with
Erik's #2 to go with fries and a super-sized coke :)


On Apr 6, 2005 11:42 PM, Erik Westra <[EMAIL PROTECTED]> wrote:
> 
> Im sure we can lay out allot of possibilities, but that's not what u
> want.
> 
> There are two possible reasons for the fact that u would like to
> instantiate a class runtime (via createChild):
> 
> 1. U want your main application to be as light as possible.
> 2. U don't know (at compile time) which class will represent the child.
> 
> My guess is that number 2 is the one u are after. To achieve that goal
> take the following steps.
> 
> A.
> Place the following code inside your initialize function in your main
> application:
> 
> Components;
> 
> B.
> Create (in the same dir as the main application) a 'Components.as' file,
> this file contains the following code:
> 
> class Components
> {
>         public function Components()
>         {
>                 //put all possible children inhere
>                 com.myProject.MyClass;
>         };
> };
> 
> The above two steps make sure the possible childs are included in the
> flex application (they are compiled in the resulting swf).
> 
> C.
> Create a function in your application that looks like this:
> 
> public function getClassRef(classPath_str:String):Object
> {
>         var classRef_obj:Object = _global;
>         var class_array:Array = classPath_str.split(".");
> 
>         for (var i = 0; i < class_array.length; i++)
>         {
>                 classRef_obj = classRef_obj[class_array[i]];
>         };
> 
>         return classRef_obj;
> };
> 
> D.
> In the initialize function u can create a child like this:
> 
> baseContainer.createChild(getClassRef("com.myProject.MyClass"));
> 
> I hope this helps :)
> 
> Greetz Erik
> 
> 
> -----Original Message-----
> From: Scott Barnes [mailto:[EMAIL PROTECTED]
> Sent: woensdag 6 april 2005 13:55
> To: flexcoders@yahoogroups.com
> Subject: Re: [flexcoders] Re: createChild dynamically via DB arguments..
> 
> Heres a test for yas:
> 
> Inside a new FLEX app directory (ie start fresh), create a dir, then
> inside that dir, create another and another (go as deep as ya want),
> then finally create a mxml file.
> 
> Then create an simple class file, and instantiate it via initialize() on
> mx.Application, then inside this class, do the same as you did (make as
> many nested ones as you want if need be) then at some point, simply do
> this
> 
> mx.core.Application.application.baseContainer.createChild(blah[arg1][arg
> 2]
> etc..)
> 
> Then explain if you can / want to, how the hell that works. As I must be
> dumber then originally thought as i can't seem to connect the dots on
> how the hell that works? hell i'm struggling to even explain it....
> (also i put another sequence of the above inside the
> unknown-loaded-at-runtime-class and they came up aswell heh).
> 
> imho its as if at compile time, the entire app is packaged together, and
> seperated into whats FLASH code and whats other, if other do i embed it
> inside the swf and all that... i''ll pop the hood a later day (if i can
> figure it out) but *shrug* my level of FLEX expertises ends here hehehe.
> 
> _level0["com"] or _global["com"] etc  won't work. As well as
> findClass();
> 
> On a side note/question. I am also unsure if (hell i have no idea to
> test) whether or not if you have assets embedded inside the mxml files
> in question (even declared as RSL) will they request a new asset per
> instantiation...
> 
> Any input / help is most welcomed heh.
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 


-- 
Regards,
Scott Barnes
http://www.mossyblog.com
http://www.flexcoder.com (Coming Soon)


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to