I think if .property is a string or other "primitive", you cannot pass a
reference to it but will always get a copy of the data.

 

Instead, why not pass a reference to the entire object, and access
.property within the consuming coomponent?

 

<comp: SomeCustomComponent source="{model.someObject.currentObject}" />

 

class SomeCustomComponent{
 public var source:Object;           //THIS SHOULD BE TYPED SPECIFICALLY
if possible

 

source.property = "mystring";   //shold update the property on the
"model.someObject.currentObject"

 

Tracy

 

 

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Ralf Bokelberg
Sent: Tuesday, March 13, 2007 10:59 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: Passing an object reference as a property

 

In the older flash days we had eval to achieve this. Now you need to
implement it on your own. 
Split the string at the dots, start from a top object and dereference
one property after the other until you get to the last part of the
string. 

Cheers
Ralf. 

On 3/13/07, greenfishinwater <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

In simple terms I think what kevin wants to do is:

var x;
var myvar;
var value;

function A(varname, value) {
varname = value)
}

myvar = "x";
value = 42;
A(myvar, value);

The required result is that the variable x should contain the value 42.

I don't know how to to this.

Andrew

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Roman Protsiuk"
<[EMAIL PROTECTED]> wrote:
>
> Hard to understand what exactly do you need and how... :)
> What is parent? Is it the object whose property you are trying to
access? Or
> is it the object which has 'model' as a property? In both cases you
can get
> property value by parsing the string your method gets.
> 
> R.
> 

> On 13 Mar 2007 07:17:12 -0700, Kevin <[EMAIL PROTECTED]> wrote:
> >
> > I think I need to be a little clearer about what I need.
> >
> > let's say i have an instance of an object property somewhere:
> >
> > model.someObject.currentObject.name
<http://model.someObject.currentObject.name> 
> >
> > I want to pass that reference location (not the value) through a
component
> > like this:
> >
> > source="model.someObject.currentObject.name
<http://model.someObject.currentObject.name> "
> >
> > so that inside the component I can update the object using the
reference:
> >
> > (this is what I don't know how to do)
> > parent[source] = someValue;
> >
> > If I use the curly braces it just binds the object value (not a
location
> > reference) to the property source. It seems the <mx:Binding > tag
is doing
> > a similar thing, but unfortunately it's one of those classes that
I can't
> > look inside to see how they do it!
> >
> > Does this make more sense about what I am trying to do?
> >
> > Thanks, Kevin
> >
> >
> >
> >
> >
> > On Mar 12, 2007, at 11:42 PM, Gordon Smith wrote:
> >
> >
> > I suspect you meant to say that trace(source) is tracing out the
string "
> > model.someObject.currentObject".
> >
> > I think you want
> >
> > <comp:SomeCustomComponent
source="{model.someObject.currentObject}"/>
> >
> > - Gordon
> >
> > ------------------------------



> > *From:* flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>  [mailto: flexcoders
<mailto:flexcoders>  <flexcoders>@
> > yahoogroups.com <http://yahoogroups.com> ] *On Behalf Of *Kevin
> > *Sent:* Monday, March 12, 2007 8:22 PM
> > *To:* flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com> 
> > *Subject:* [flexcoders] Passing an object reference as a property
> >
> > I would like to pass an object path through a property of another
> > class, but can't figure out how to do it.
> >
> > model.someObject.currentObject (the ML variable)
> >
> > <comp: SomeCustomComponent source="model.someObject.currentObject"
/>
> >
> > class SomeCustomComponent{
> >
> > public var source:Object;
> >
> > function test(){
> >
> > trace(model.someObject.currentObjec);
> >
> > }
> >
> > }
> >
> > This outputs the string "model.someObject.currentObject" rather than
> > the variable value at - model.someObject.currentObject
> >
> > thanks for the insight.
> >
> > - kevin
> >
> >
> >
> >
>




-- 
Ralf Bokelberg <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> >
Flex & Flash Consultant based in Cologne/Germany
Phone +49 (0) 221 530 15 35 

 

Reply via email to