Oh I get it now,

attr.edges isn't an array of edge objects, its just an object with a
series of properties that define an edge to your shape?

If that is the case and you wish to iterate over the properties and
execute set on them explicitly, you could do something like...

var arr = $H(attr.edges).keys();

arr.each(function(edgeProperty){

   this[edgeProperty].set(...);

}, attr.edges);



On Jul 14, 3:09 pm, ronman <ron.new...@gmail.com> wrote:
> Here's what I'm doing now:
>  $A(attr.edges).each(function(edge) {
>     edge.set(id, new GraphEdge(cv, id, edge));
>
> }, this);
>
> Same result.  The iterator.length shows zero and the inside of the
> loop never executes.  But the iterator is (correctly, I think) 'Object
> Brainwriting =Object'
>
> Just casting around, I also tried taking off the binding to 'this' at
> the end, doesn't help.
>
> As before, I'm not getting why anything whatsoever that's in an array
> shouldn't automatically return length > 0.
>
> On Jul 14, 1:47 pm, Matt Foster <mattfoste...@gmail.com> wrote:
>
> > >  $A(attr.edges).each(function(edge) {
> > >      this.edge.set(id, new GraphEdge(cv, id, edge));
> > >    }, this);
>
> > edge is your variable, why bother trying to set function ownership?
> > The function is sent the parameter it needs to act upon.  Just remove
> > "this" from your "this.edge..." line and you should be good.
>
> > --
>
> >http://positionabsolute.net
>
> > On Jul 14, 2:28 pm, ronman <ron.new...@gmail.com> wrote:
>
> > > This is a newbie question, but I learn a lot every time I ask.
>
> > > Why do some objects return a zero length?
>
> > > I'm doing Array.each.  In the array at this particular time is a
> > > single object.  Firebug describes that object as
>
> > > Object Brainwriting color=black penwidth=0.5 fontname=Arial
>
> > > and I iterate through the array this way:
> > >  $A(attr.edges).each(function(edge) {
> > >      this.edge.set(id, new GraphEdge(cv, id, edge));
> > >    }, this);
>
> > > But in Prototype's each method the 'edge' iterator (the Brainwriting
> > > Object), returns zero length:
> > > function $A(iterable) {
> > >   if (!iterable) return [];
> > >   if (iterable.toArray) return iterable.toArray();
> > >   var length = iterable.length || 0, results = new Array(length);
> > >    // LENGTH NOW IS ZERO
> > >   while (length--) results[length] = iterable[length];
> > >   return results;
>
> > > }
>
> > > Maybe the Brainwriting Object is not iterable, but I would expect $A
> > > (attr.edges) to have made it so before my call to each().
>
> > > Surely I'm not expected to assign a length attribute to objects myself
> > > - just lilke 'penwidth' and 'color' were assigned - in order to make
> > > Array.each() work on objects.  Why doesn't the Object.length return
> > > non-zero when any kind of Object is instantiated?
>
> > > I'm using Firefox 3.0.10.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to