[flexcoders] Re: opposite of outterDocument?

2009-01-22 Thread oneworld95
The way I did this (and it's probably not the most efficient) was this:
 - User clicked a button inside the mx:component tag.
 - The click call passed a reference to the VBox container to the
outer document function.
 - In the outer document function, I'd use the reference like this: 

var vb:VBox = vbox; // vbox is the reference to object in component
var text:TextInput = vb.getChildAt(2) as TextInput;

I wish there was a cleaner way, like setting an ID on the mx:component
tag and then referencing its children. But I think the component is
treated as a different class altogether.

- Alex

--- In flexcoders@yahoogroups.com, dnk d.k.emailli...@... wrote:

 Is there something the opposite of outterDocument to access vars and  
 methods inside of a mx:component tag?
 
 or is it as simple as (no where near my flex machine):
 
 mx:Component id=something
 
   custom:mycomp /
 
 /mx:Component
 
 
 script
 
 something.mymethod;
 
 
 
 
 Thanks!
 
 d





[flexcoders] Re: opposite of outterDocument?

2009-01-22 Thread Amy
--- In flexcoders@yahoogroups.com, dnk d.k.emailli...@... wrote:

 Is there something the opposite of outterDocument to access vars and  
 methods inside of a mx:component tag?
 
 or is it as simple as (no where near my flex machine):
 
 mx:Component id=something
 
   custom:mycomp /
 
 /mx:Component
 
 
 script
 
 something.mymethod;

If you're actually _in_ the component, then you can use this.

Otherwise, check out 
http://www.adobe.com/devnet/flex/articles/loose_coupling.html 
http://www.adobe.com/devnet/flex/articles/graduating_pt1.html



Re: [flexcoders] Re: opposite of outterDocument?

2009-01-22 Thread dnk
Well I tried refernecing it that way, but no go.

The other thing is that you are not allowed to put an id on  the root  
tag of a component. Ends up with this error:


id attribute is not allowed on the root tag of a component.

So I am not sure how you would be able to reference the child of the  
mx:component tag.

You can set an id on the mx:component tag itself.. .and i was hoping  
to reference it that way, but that gives me a :

: Call to a possibly undefined method goToDownload through a reference  
with static type mx.core:ClassFactory

I had mentioned that in one of my other responses.

d




On 22-Jan-09, at 8:26 AM, oneworld95 wrote:

 The way I did this (and it's probably not the most efficient) was  
 this:
 - User clicked a button inside the mx:component tag.
 - The click call passed a reference to the VBox container to the
 outer document function.
 - In the outer document function, I'd use the reference like this:

 var vb:VBox = vbox; // vbox is the reference to object in component
 var text:TextInput = vb.getChildAt(2) as TextInput;

 I wish there was a cleaner way, like setting an ID on the mx:component
 tag and then referencing its children. But I think the component is
 treated as a different class altogether.

 - Alex

 --- In flexcoders@yahoogroups.com, dnk d.k.emailli...@... wrote:
 
  Is there something the opposite of outterDocument to access vars and
  methods inside of a mx:component tag?
 
  or is it as simple as (no where near my flex machine):
 
  mx:Component id=something
 
  custom:mycomp /
 
  /mx:Component
 
 
  script
 
  something.mymethod;
 
 
 
 
  Thanks!
 
  d


Re: [flexcoders] Re: opposite of outterDocument?

2009-01-22 Thread dnk

On 22-Jan-09, at 9:00 AM, Amy wrote:

 --- In flexcoders@yahoogroups.com, dnk d.k.emailli...@... wrote:
 
  Is there something the opposite of outterDocument to access vars and
  methods inside of a mx:component tag?
 
  or is it as simple as (no where near my flex machine):
 
  mx:Component id=something
 
  custom:mycomp /
 
  /mx:Component
 
 
  script
 
  something.mymethod;

 If you're actually _in_ the component, then you can use this.

 Otherwise, check out
 http://www.adobe.com/devnet/flex/articles/loose_coupling.html
 http://www.adobe.com/devnet/flex/articles/graduating_pt1.html



No the script is called in the mxml file that has the below code:

mx:Component id=something

custom:mycomp /

/mx:Component

This is why i had referenced the opposite of outerDocument - because  
it would accomplish the opposite of what I am trying to do (accessing  
methods, etc inside of a component tag).

d

.




RE: [flexcoders] Re: opposite of outterDocument?

2009-01-22 Thread Alex Harui
Remember that what is inside an mx:Component tag is a template for a renderer 
that is often instantiated many times and recycled for use with different data 
objects.  Therefore, there is no one reference to it.

There are APIs like indexToItemRenderer and references to an itemRenderer in 
various events like ITEM_ROLL_OVER, but it is considered bad practice.  The 
renderer should be deriving everything by pulling from its data field and the 
outerDocument

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of dnk
Sent: Thursday, January 22, 2009 9:02 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: opposite of outterDocument?


Well I tried refernecing it that way, but no go.

The other thing is that you are not allowed to put an id on the root
tag of a component. Ends up with this error:

id attribute is not allowed on the root tag of a component.

So I am not sure how you would be able to reference the child of the
mx:component tag.

You can set an id on the mx:component tag itself.. .and i was hoping
to reference it that way, but that gives me a :

: Call to a possibly undefined method goToDownload through a reference
with static type mx.core:ClassFactory

I had mentioned that in one of my other responses.

d

On 22-Jan-09, at 8:26 AM, oneworld95 wrote:

 The way I did this (and it's probably not the most efficient) was
 this:
 - User clicked a button inside the mx:component tag.
 - The click call passed a reference to the VBox container to the
 outer document function.
 - In the outer document function, I'd use the reference like this:

 var vb:VBox = vbox; // vbox is the reference to object in component
 var text:TextInput = vb.getChildAt(2) as TextInput;

 I wish there was a cleaner way, like setting an ID on the mx:component
 tag and then referencing its children. But I think the component is
 treated as a different class altogether.

 - Alex

 --- In flexcoders@yahoogroups.commailto:flexcoders%40yahoogroups.com, dnk 
 d.k.emailli...@... wrote:
 
  Is there something the opposite of outterDocument to access vars and
  methods inside of a mx:component tag?
 
  or is it as simple as (no where near my flex machine):
 
  mx:Component id=something
 
  custom:mycomp /
 
  /mx:Component
 
 
  script
 
  something.mymethod;
 
 
 
 
  Thanks!
 
  d



RE: [flexcoders] Re: opposite of outterDocument?

2009-01-22 Thread Tracy Spratt
Is this component tag used as an itemRenderer?  If so, I would
reconsider your approach.  It is rarely useful to attempt to manipulate
a renderer from the outside.  Its behavior should be driven from its
current dataProvider item and you should manipulate the rendere instance
by updating the dataProvider.

 

What is your myMethod going to do?

Tracy Spratt 
Lariat Services 

Flex development bandwidth available 



From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of dnk
Sent: Thursday, January 22, 2009 12:09 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: opposite of outterDocument?

 


On 22-Jan-09, at 9:00 AM, Amy wrote:

 --- In flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com , dnk d.k.emailli...@... wrote:
 
  Is there something the opposite of outterDocument to access vars and
  methods inside of a mx:component tag?
 
  or is it as simple as (no where near my flex machine):
 
  mx:Component id=something
 
  custom:mycomp /
 
  /mx:Component
 
 
  script
 
  something.mymethod;

 If you're actually _in_ the component, then you can use this.

 Otherwise, check out
 http://www.adobe.com/devnet/flex/articles/loose_coupling.html
http://www.adobe.com/devnet/flex/articles/loose_coupling.html 
 http://www.adobe.com/devnet/flex/articles/graduating_pt1.html
http://www.adobe.com/devnet/flex/articles/graduating_pt1.html 


No the script is called in the mxml file that has the below code:

mx:Component id=something

custom:mycomp /

/mx:Component

This is why i had referenced the opposite of outerDocument - because 
it would accomplish the opposite of what I am trying to do (accessing 
methods, etc inside of a component tag).

d

.