Ah, I see. It seems that a more fundamental issue here is that the
Tree automatically absorbs the entire XML structure -- so the <rtmp>,
<introframe> and <title> nodes become child tree nodes of the <video>
node, rather than its properties.
Without modifications to the Tree component, one way to do this would
be to pre-parse your XML data and store properties of each video in a
separate data structure. An array would probably be the fastest. So
for example, if you have something like this:
<videos>
<video label="Foo">
<Foo's properties...>
</video>
<video label="Bar">
<Bar's properties...>
</video>
</videos>
You would parse this, and create two data structures:
An XML:
<videos>
<video label="Foo" id="0" />
<video label="Bar" id="1" />
</videos>
And an Array:
[{XML object of Foo's properties}, {XML object of Bar's properties}].
If you use the generated XML to populate the Tree, the id attribute
will become available for each item in the tree you click on -- you
can then use that id to look up the specific data, however complex, in
the Array.
Does this solution make sense?
Thanks,
Allen
--- In ydn-flash@yahoogroups.com, "Randy Troppmann"
<randy.troppmann@...> wrote:
>
> Hey Allen,
> Thanks for the response. I think that is a very convenient way to
populate
> the tree and it works nicely. What I am trying to do is associate
data with
> a "label" level of the tree. For example:
>
> <videos>
>
> <video label="Shell Video" >
> <rtmp url="rtmp://flashmedia.foo.ca:1935/foo_ca_streams"/>
> <introFrame url="titles/shell_small.jpg"/>
> <title value="Streaming video example 320x240"/>
> <autoPlay value="false"/>
> </video>
> <video label="Amy Video" >
> <rtmp url="rtmp://flashmedia.foo.ca:1935/foot_ca_streams"/>
> <introFrame url="titles/tenacity.jpg"/>
> <title value="Streaming video with xml-based chapters"/>
> <autoPlay value="false"/>
> <chapters>
> <chapter time="20" title="This video is squished on purpose; should
> be 622 x 350"/>
> <chapter time="60" title="Sample chapter 2"/>
> </chapters>
> </video>
> </videos>
>
> In this case the <video> child is the clickable part of the tree and I
> would like a way to bind the children of <video> to the click event so
> I can pass in the associated parameters. As you can see the structure
> is more complicated than putting a value in an attribute of the
> <video> node. I would like to parse out the attributes and reference
> them in the click event somehow. I hope that makes sense. Any ideas
> are welcome.
>
> Cheers,
>
> Randy Troppmann
>
>
>
>
>
> On Wed, Jun 25, 2008 at 4:13 PM, Allen Rabinovich <allenrabinovich@...>
> wrote:
>
> > Hi Randy,
> >
> > Sorry for the delayed response. Can you elaborate what you mean by
> > that? The way the Tree works right now is that it populates each item
> > with the properties specified in the source XML, and those properties
> > become available as variables in the item object (exactly how the List
> > does it). Does that make sense? For example, let's say this is the
> > source XML for the Tree:
> >
> > <root>
> > <node label="Foo" someproperty="blah" />
> > <node label="Bar" someother="Bazz" />
> > </root>
> >
> > This Tree will contain two items, Foo and Bar. When you click on the
> > item Foo, the Tree will dispatch an itemClick event, which will
> > contain an item property. That item is an Object that has
> > someproperty="blah".
> >
> > Let me know if that answers your question.
> >
> > - Allen
> >
> > --- In ydn-flash@yahoogroups.com <ydn-flash%40yahoogroups.com>, "Randy
> > Troppmann"
> >
> > <randy.troppmann@> wrote:
> > >
> > > Is there a way to bind an object to a data provider so that a click
> > on an
> > > item can have access to parameters of that item?
> > > - Randy
> > >
> >
> >
> >
>