Thanks again TH it works great I just adjusted it to an if..else.. conditional 
statement to avoid it still adding the duplicate to the tiles on the right.  
Appreciate it!

-Sal

--- In [email protected], "turbo_vb" <timh...@...> wrote:
>
> If you need to check dups for other reasons that would work fine.  but,
> if you just need it for this particular use-case, this is simpler:
> 
> public function addButton():void
> 
> {
> 
> 
>       if ( dataRight.getItemIndex( rightTiles.selectedItem ) != -1 )
> Alert.show( "Already exists" );
> 
> 
> 
> 
> 
>       dataRight.addItem( rightTiles.selectedItem );
> 
> }
> 
> 
> 
> 
> -TH
> 
> 
> 
> --- In [email protected], "s_hernandez01" <s_hernandez01@>
> wrote:
> >
> > What about if I wanted to check for duplicates so that it will remind
> the user that this button already exists on the right?  I came up with
> something like this, but doesn't work:
> >
> > public function addButton():void{
> >     dataRight.addItem(rightTiles.selectedItem);
> >     checkDuplicates();
> >    }
> >
> >    public function checkDuplicates():void{
> >     for(var i:int=0; i < dataRight.length; i++){
> >      if(dataLeft[i].id==dataRight[i].id){
> >       Alert.show("Already exists");
> >      }
> >     }
> >    }
> >
> > -Sal
> >
> > --- In [email protected], "s_hernandez01" s_hernandez01@
> wrote:
> > >
> > > hey thanks TH, i knew it was something with one line of code. You
> rock! This was driving me nuts.
> > >
> > > Sal
> > >
> > > --- In [email protected], "turbo_vb" <TimHoff@> wrote:
> > > >
> > > > Because guys like Gordon are here, I'll also say that Instantiate
> is the correct word; instead of initialize. :)
> > > >
> > > > -TH
> > > >
> > > > --- In [email protected], "turbo_vb" <TimHoff@> wrote:
> > > > >
> > > > > Man, I always forget at least one thing.   You also need to
> initialize
> > > > > the second ArrayCollection().
> > > > >
> > > > >
> > > > > [Bindable] public var dataRight:ArrayCollection= new
> ArrayCollection();
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Might want to give the itemRenderer a background, so that the
> double
> > > > > clicks will be triggered on the entire area.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > -TH
> > > > >
> > > > >
> > > > >
> > > > > --- In [email protected], "turbo_vb" <TimHoff@> wrote:
> > > > > >
> > > > > >
> > > > > > Hey Sal,
> > > > > > minor tweaks:
> > > > > >
> > > > > > public function addButton():void
> > > > > >
> > > > > > {
> > > > > >
> > > > > > dataRight.addItem( rightTiles.selectedItem );
> > > > > >
> > > > > > }
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > and:
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > <mx:HTTPService id="btnSrv"
> > > > > >
> > > > > > url="buttonData.xml"
> > > > > >
> > > > > > useProxy="false"
> > > > > >
> > > > > > result="handleQueryResult(event)"
> > > > > >
> > > > > > showBusyCursor="true"
> > > > > >
> > > > > > resultFormat="object"/>
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > -TH
> > > > > >
> > > > > >
> > > > > >
> > > > > > --- In [email protected], "s_hernandez01"
> s_hernandez01@
> > > > > > wrote:
> > > > > > >
> > > > > > > I am having trouble understanding the addItem method in AS3
> with
> > > > > Flex.
> > > > > > I'm trying to simply add the item renderer with all it's data
> from
> > > > > > tilelist to tilelist.  I'm using two arraycollections to do
> the
> > > > > transfer
> > > > > > and the data is being populated through an xml file.  I know
> it's just
> > > > > > maybe 2 or 3 lines of code that I probably need, but can
> someone help
> > > > > > me, please?  Thanks
> > > > > > >
> > > > > > >
> > > > > > > // SAMPLE XML FILE
> > > > > > >
> > > > > > > <buttonData>
> > > > > > >     <product id="1">
> > > > > > >         <image>btnSkins/action_btn.png</image>
> > > > > > >         <price>10</price>
> > > > > > >     </product>
> > > > > > >     <product id="2">
> > > > > > >         <image>btnSkins/awards_btn.png</image>
> > > > > > >      <price>15</price>
> > > > > > >     </product>
> > > > > > >     <product id="3">
> > > > > > >         <image>btnSkins/beer_btn.png</image>
> > > > > > >      <price>20</price>
> > > > > > >     </product>
> > > > > > >     <product id="4">
> > > > > > >         <image>btnSkins/blog_btn.png</image>
> > > > > > >      <price>25</price>
> > > > > > >     </product>
> > > > > > > </buttonData>
> > > > > > >
> > > > > > >
> > > > > > > // MAIN FILE
> > > > > > >
> > > > > > > <?xml version="1.0" encoding="utf-8"?>
> > > > > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> > > > > > layout="horizontal" creationComplete="btnSrv.send()">
> > > > > > >
> > > > > > >  <mx:Script>
> > > > > > >   <![CDATA[
> > > > > > >    import mx.collections.ArrayCollection;
> > > > > > >    import mx.rpc.events.ResultEvent;
> > > > > > >
> > > > > > >    [Bindable] public var dataLeft:ArrayCollection;
> > > > > > >    [Bindable] public var dataRight:ArrayCollection;
> > > > > > >
> > > > > > >    public function
> handleQueryResult(event:ResultEvent):void{
> > > > > > >     dataLeft = btnSrv.lastResult.buttonData.product;
> > > > > > >    }
> > > > > > >
> > > > > > >    public function addButton():void{
> > > > > > >     var item:Object = new Object();
> > > > > > >     dataRight.addItem(item);
> > > > > > >    }
> > > > > > >   ]]>
> > > > > > >  </mx:Script>
> > > > > > >
> > > > > > >  <mx:HTTPService id="btnSrv" url="buttonData.xml"
> useProxy="false"
> > > > > > >   result="handleQueryResult(event)" showBusyCursor="true"/>
> > > > > > >
> > > > > > >  <mx:TileList id="rightTiles" width="100%" height="50%"
> > > > > > dataProvider="{dataLeft}" itemRenderer="ipodThumb"
> columnWidth="94"
> > > > > > rowHeight="80"
> > > > > > >   doubleClickEnabled="true" doubleClick="addButton()"/>
> > > > > > >
> > > > > > >  <mx:TileList id="leftTiles" width="100%" height="50%"
> > > > > > dataProvider="{dataRight}" itemRenderer="ipodThumb"
> columnWidth="94"
> > > > > > rowHeight="80"/>
> > > > > > > </mx:Application>
> > > > > > >
> > > > > > >
> > > > > > > // ITEM RENDERER
> > > > > > >
> > > > > > > <?xml version="1.0" encoding="utf-8"?>
> > > > > > > <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml";
> width="108"
> > > > > > height="83">
> > > > > > >
> > > > > > >  <mx:Image source="{data.image}" verticalAlign="middle"
> > > > > > horizontalAlign="center" right="5" bottom="0" left="5"
> top="0"/>
> > > > > > >
> > > > > > > </mx:Canvas>
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>


Reply via email to