Re: [flexcoders] Common base class for components

2009-01-30 Thread Martyn Bowis
Hi Jules,

Object Oriented programming in my mind is about making use of references 
to objects.  With this in mind, here is a way I use to centralise common 
functionality (functions) that I can access throughout my application:

1. Create an object in the Application mxml file - this will be 
referenced throughout your application components
eg: objApp:Object = new Object();

2. Create functions inside a script block in the Application mxml file
eg:
public function myUsefulFunction(): void {
...
}

3. Add references to my functions to objApp object - no () after the 
function name as it is a reference to it, not a call to it
eg: objApp.myUsefulFunction = myUsefulFunction;

I can also include function classes here and make reference to their 
functions

4. Pass objApp as a reference to each component - I must be sure that 
the deepest component is chained back to the Application mxml by passing 
this reference through all its parents
eg: 

5. Inside each component, bind objApp
eg:
[Bindable]
public var objApp:Object;

6. Call my functions from whereever I want to, from any component that 
has a reference to objApp
eg: objApp.myUsefulFunction();

7. I am not just limited to passing references to functions this way 
either.  I can pass references to child objects and even move them 
around the stage, etc. also
eg: objApp.myPanel.x = objApp.myOtherPanel.x + objApp.myOtherPanel.width 
+ 10;

Hope this helps you.  Works really well for me.  It seems a very easy 
way to use the power of object oriented referencing to talk to anything, 
anywhere in an application.  And if I ever want to know anything about 
any object, I can usually query it via reference to objApp.

Could call it the objApp framework if it hasn't already got a name :o)

Cheers,
Martyn

Jules Suggate wrote:
>
> Is it possible for an MXML file to implement an interface? Sounds 
> intriguing ... but won't resolve my issue unfortunately. It's the 
> implementation code that I want them to share.
>
> I have developers on my team who are less than keen on having to 
> duplicate repetitive code around the place -- they want to focus on 
> cool effects, state transitions and backend integration :-)
>
> And I don't want repeated code everywhere in the app since if we want 
> to change something, there'll eventullay be hundreds of places where 
> we have to do so if the code is copy+pasted around the place...
>
> On Fri, Jan 30, 2009 at 05:25, Fotis Chatzinikos 
> mailto:fotis.chatzini...@gmail.com>> wrote:
>
> why do not you make your components implement an interface with
> these methods you describe?
>
>
> On Thu, Jan 29, 2009 at 10:54 AM, Jules Suggate
> mailto:julian.sugg...@gmail.com>> wrote:
>
> Just to resume this thread, what I meant was to still use MXML
> and all the Flex components, but to introduce common
> functionality to all our Views (mxml files). Perhaps it's
> better to think of weaving this in than using inheritance,
> since that would require multiple inheritance AFAICT.
>
> I don't want anything fancy -- just a getter/setter pair:
>
> public function get model():IViewModel
> {
>// some common code
> }
> private var _model:IViewModel;
> public function set model(value:IViewModel):void
> {
>// more common code
> }
>
> To save writing out this code again and again, would I have to
> put this code in an include file, and include from each View?
>
>
>
> On Thu, Dec 18, 2008 at 06:41, Alex Harui  > wrote:
>
> In theory, if your base class implements IUIComponent,
> then your visual components will work in Flex
>
>  
>
> *From:* flexcoders@yahoogroups.com
> 
> [mailto:flexcoders@yahoogroups.com
> ] *On Behalf Of *Jules
> Suggate
> *Sent:* Wednesday, December 17, 2008 8:56 AM
> *To:* flexcoders@yahoogroups.com
> 
> *Subject:* [flexcoders] Common base class for components
>
>  
>
> Hi list, anyone know if it's possible to have all our
> components inherit from a common base component of our own
> making?
>
> There are some things in our app that every View component
> will have to do at loadtime, and it'd be nice to just
> write that code once and have all the other components
> inherit it...
>
> Last time I checked in Flex 3 Beta 2 there was some vague
> suggestion of using "Template Components", but that seemed
> like an afterthought in the SDK at the time. Just thought
> I'd check to see if you knew of any tricks for doing it :)
>
> Perhaps eve

Re: [flexcoders] Common base class for components

2009-01-29 Thread Jules Suggate
Is it possible for an MXML file to implement an interface? Sounds intriguing
... but won't resolve my issue unfortunately. It's the implementation code
that I want them to share.

I have developers on my team who are less than keen on having to duplicate
repetitive code around the place -- they want to focus on cool effects,
state transitions and backend integration :-)

And I don't want repeated code everywhere in the app since if we want to
change something, there'll eventullay be hundreds of places where we have to
do so if the code is copy+pasted around the place...

On Fri, Jan 30, 2009 at 05:25, Fotis Chatzinikos <
fotis.chatzini...@gmail.com> wrote:

>   why do not you make your components implement an interface with these
> methods you describe?
>
>
> On Thu, Jan 29, 2009 at 10:54 AM, Jules Suggate 
> wrote:
>
>>   Just to resume this thread, what I meant was to still use MXML and all
>> the Flex components, but to introduce common functionality to all our Views
>> (mxml files). Perhaps it's better to think of weaving this in than using
>> inheritance, since that would require multiple inheritance AFAICT.
>>
>> I don't want anything fancy -- just a getter/setter pair:
>>
>> public function get model():IViewModel
>> {
>>// some common code
>> }
>> private var _model:IViewModel;
>> public function set model(value:IViewModel):void
>> {
>>// more common code
>> }
>>
>> To save writing out this code again and again, would I have to put this
>> code in an include file, and include from each View?
>>
>>
>> On Thu, Dec 18, 2008 at 06:41, Alex Harui  wrote:
>>
>>>In theory, if your base class implements IUIComponent, then your
>>> visual components will work in Flex
>>>
>>>
>>>
>>> *From:* flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] *On
>>> Behalf Of *Jules Suggate
>>> *Sent:* Wednesday, December 17, 2008 8:56 AM
>>> *To:* flexcoders@yahoogroups.com
>>> *Subject:* [flexcoders] Common base class for components
>>>
>>>
>>>
>>> Hi list, anyone know if it's possible to have all our components inherit
>>> from a common base component of our own making?
>>>
>>> There are some things in our app that every View component will have to
>>> do at loadtime, and it'd be nice to just write that code once and have all
>>> the other components inherit it...
>>>
>>> Last time I checked in Flex 3 Beta 2 there was some vague suggestion of
>>> using "Template Components", but that seemed like an afterthought in the SDK
>>> at the time. Just thought I'd check to see if you knew of any tricks for
>>> doing it :)
>>>
>>> Perhaps even an include file would be the way to go...
>>>
>>>
>>
>>
>> --
>> --
>> Jules Suggate
>> Owner and Technical Lead
>> Uphill Sprint Limited
>>
>> +64-21-157-8562
>>
>
>
>
> --
> Fotis Chatzinikos, Ph.D.
> Founder,
> Phinnovation
> fotis.chatzini...@gmail.com,
>  
>



-- 
--
Jules Suggate
Owner and Technical Lead
Uphill Sprint Limited

+64-21-157-8562


Re: [flexcoders] Common base class for components

2009-01-29 Thread Fotis Chatzinikos
why do not you make your components implement an interface with these
methods you describe?


On Thu, Jan 29, 2009 at 10:54 AM, Jules Suggate wrote:

>   Just to resume this thread, what I meant was to still use MXML and all
> the Flex components, but to introduce common functionality to all our Views
> (mxml files). Perhaps it's better to think of weaving this in than using
> inheritance, since that would require multiple inheritance AFAICT.
>
> I don't want anything fancy -- just a getter/setter pair:
>
> public function get model():IViewModel
> {
>// some common code
> }
> private var _model:IViewModel;
> public function set model(value:IViewModel):void
> {
>// more common code
> }
>
> To save writing out this code again and again, would I have to put this
> code in an include file, and include from each View?
>
>
> On Thu, Dec 18, 2008 at 06:41, Alex Harui  wrote:
>
>>In theory, if your base class implements IUIComponent, then your
>> visual components will work in Flex
>>
>>
>>
>> *From:* flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] *On
>> Behalf Of *Jules Suggate
>> *Sent:* Wednesday, December 17, 2008 8:56 AM
>> *To:* flexcoders@yahoogroups.com
>> *Subject:* [flexcoders] Common base class for components
>>
>>
>>
>> Hi list, anyone know if it's possible to have all our components inherit
>> from a common base component of our own making?
>>
>> There are some things in our app that every View component will have to do
>> at loadtime, and it'd be nice to just write that code once and have all the
>> other components inherit it...
>>
>> Last time I checked in Flex 3 Beta 2 there was some vague suggestion of
>> using "Template Components", but that seemed like an afterthought in the SDK
>> at the time. Just thought I'd check to see if you knew of any tricks for
>> doing it :)
>>
>> Perhaps even an include file would be the way to go...
>>
>>
>
>
> --
> --
> Jules Suggate
> Owner and Technical Lead
> Uphill Sprint Limited
>
> +64-21-157-8562
>  
>



-- 
Fotis Chatzinikos, Ph.D.
Founder,
Phinnovation
fotis.chatzini...@gmail.com,


Re: [flexcoders] Common base class for components

2009-01-29 Thread Jules Suggate
Just to resume this thread, what I meant was to still use MXML and all the
Flex components, but to introduce common functionality to all our Views
(mxml files). Perhaps it's better to think of weaving this in than using
inheritance, since that would require multiple inheritance AFAICT.

I don't want anything fancy -- just a getter/setter pair:

public function get model():IViewModel
{
   // some common code
}
private var _model:IViewModel;
public function set model(value:IViewModel):void
{
   // more common code
}

To save writing out this code again and again, would I have to put this code
in an include file, and include from each View?

On Thu, Dec 18, 2008 at 06:41, Alex Harui  wrote:

>In theory, if your base class implements IUIComponent, then your visual
> components will work in Flex
>
>
>
> *From:* flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] *On
> Behalf Of *Jules Suggate
> *Sent:* Wednesday, December 17, 2008 8:56 AM
> *To:* flexcoders@yahoogroups.com
> *Subject:* [flexcoders] Common base class for components
>
>
>
> Hi list, anyone know if it's possible to have all our components inherit
> from a common base component of our own making?
>
> There are some things in our app that every View component will have to do
> at loadtime, and it'd be nice to just write that code once and have all the
> other components inherit it...
>
> Last time I checked in Flex 3 Beta 2 there was some vague suggestion of
> using "Template Components", but that seemed like an afterthought in the SDK
> at the time. Just thought I'd check to see if you knew of any tricks for
> doing it :)
>
> Perhaps even an include file would be the way to go...
>
>   
>



-- 
--
Jules Suggate
Owner and Technical Lead
Uphill Sprint Limited

+64-21-157-8562


RE: [flexcoders] Common base class for components

2008-12-17 Thread Alex Harui
In theory, if your base class implements IUIComponent, then your visual 
components will work in Flex

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of Jules Suggate
Sent: Wednesday, December 17, 2008 8:56 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Common base class for components


Hi list, anyone know if it's possible to have all our components inherit from a 
common base component of our own making?

There are some things in our app that every View component will have to do at 
loadtime, and it'd be nice to just write that code once and have all the other 
components inherit it...

Last time I checked in Flex 3 Beta 2 there was some vague suggestion of using 
"Template Components", but that seemed like an afterthought in the SDK at the 
time. Just thought I'd check to see if you knew of any tricks for doing it :)

Perhaps even an include file would be the way to go...