You’re using the List addItemAt method instead of the DataProvider addItemsAt method.  I think you want to use _root.modelImage2.photo.addItemsAt(0, tilelistAllImage.selectedItems);

as the body of your addLibrary method, no need for the for loop.

 

Matt


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of P Trisnadi
Sent: Thursday, July 07, 2005 2:10 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Added image/s in TileList is/are not shown

 

Not sure why second message was also truncated. Let's
try this again...
----------
Thanks for your interest and notice, Scott. To recap:
I have a TileList that shows images and their names,
read from an XML file and rendered by a CellRenderer.
When the [Add Photo] button is clicked, a createPopUp
is called. This PopUp also has a TileList that reads
another XML file with the same structure (but
different data.) Images can be selected, and when the
[Add] button is clicked selected images should be
added to the main TileList's model. However, something
is added to the TileList, but it only shows blank
tiles/undefined...

Here is the code again...

---------- XML file, both look similar ----------
<?xml version="1.0" encoding="utf-8"?>
  <photos>
   <photo><filename>image01.jpg</filename></photo>
   <photo><filename>image02.jpg</filename></photo>
   <photo><filename>image03.jpg</filename></photo>
  </photos>

---------- TileList that I want to add images in
----------
<mx:Script>
<![CDATA[
    function showImage() {
        var
popup=mx.managers.PopUpManager.createPopUp(_root,
imageBrowser, true);
    }
]]>
</mx:Script>
...
    <mx:Model id="modelImage2" source="photos2.xml"/>
     <mx:TileList id="tilelistImage"
dataProvider="{modelImage2.photo}"
cellRenderer="thumbnail2"
change="{showSelected(tilelistImage.selectedItem)}"
multipleSelection="true"/>
    <mx:Button label="Add Photo" click="showImage()"/>

---------- TileList that I want to bring images from
----------
<mx:Script>
<![CDATA[
    function addLibrary():Void {
        for (var i=0;
i<tilelistAllImage.selectedIndices.length; i++) {
          
_root.modelImage2.photo.addItemAt(0,"",tilelistAllImage.selectedItems[i]);
        }
         _root.tilelistImage.sortItems();
        this.deletePopUp();
    }
]]>
</mx:Script>

    <mx:Model id="modelImage" source="photos.xml"/>
    <mx:TileList id="tilelistAllImage"
dataProvider="{modelImage.photo}"
cellRenderer="thumbnail2"
change="{anySelected(tilelistAllImage.selectedItem)}"
multipleSelection="true"/>
    <mx:Button label="Add" id="btAdd"
click="addLibrary()"/>

---------- CellRenderer ----------
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox
xmlns:mx="http://www.macromedia.com/2003/mxml"
width="72" height="86" horizontalAlign="center"
verticalAlign="middle" horizontalGap="0"
verticalGap="0" borderStyle="none" hScrollPolicy="off"
vScrollPolicy="off">
    <mx:Script>
        var photoObj:Object;
        function setValue(str:String,item:Object) {
            if (item==undefined) {
                visible=false;
                return;
            } else {
                photoObj=item;
                visible=true;
            }
        }
    </mx:Script>
    <mx:Image source="{photoObj.filename}" width="64"
height="64" verticalAlign="middle"
horizontalAlign="center"/>
    <mx:Label text="{photoObj.filename}" width="72"
textAlign="center" fontSize="10"/>
</mx:VBox>

--------------------
Any idea why it adds blank, undefined tile here?

TIA,
- ptrisnadi


           
____________________________________________________
Sell on Yahoo! Auctions – no fees. Bid on great items. 
http://auctions.yahoo.com/


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to