У меня есть TileList с пользовательским ItemRenderer, и каждый элемент показывает изображение, которое он извлекает из данных, которые он получает от dataProvider. Странная вещь, и я понятия не имею, почему некоторые элементы показывают изображения, которые находятся не в их блоке данных, а в данных других элементов. Если я извлекаю URL-адрес изображения из его собственных данных, я понятия не имею, как можно получить URL-адрес изображения из другого элемента. Я использовал всплывающую подсказку, чтобы показать URL-адрес изображения и данные элемента, и убедился, что URL-адрес отсутствует в его данных.
Вот временный XML, который я использую:
<data>
<bs item_id="1">
<variation price="300" month="JAN" stone="Garnet" image="<?=$img_dir?>jan.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
<variation price="400" month="FEB" stone="Garnet" image="<?=$img_dir?>feb.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
<variation price="550" month="MAR" stone="Garnet" image="<?=$img_dir?>march.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
<variation price="625" month="APR" stone="Garnet" image="<?=$img_dir?>april.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
</bs>
<bs item_id="2">
<variation price="300" month="JAN" stone="Garnet" image="<?=$img_dir?>jan.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
<variation price="400" month="FEB" stone="Garnet" image="<?=$img_dir?>feb.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
<variation price="550" month="MAR" stone="Garnet" image="<?=$img_dir?>march.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
<variation price="625" month="APR" stone="Garnet" image="<?=$img_dir?>april.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
</bs>
<bs item_id="3">
<variation price="300" month="JAN" stone="Garnet" image="<?=$img_dir?>jan.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
<variation price="400" month="FEB" stone="Garnet" image="<?=$img_dir?>feb.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
<variation price="550" month="MAR" stone="Garnet" image="<?=$img_dir?>march.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
<variation price="625" month="APR" stone="Garnet" image="<?=$img_dir?>april.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
</bs>
<bs item_id="4">
<variation price="300" month="JAN" stone="Garnet" image="<?=$img_dir?>PE105-BT.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
<variation price="400" month="FEB" stone="Garnet" image="<?=$img_dir?>PE105-EM.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
<variation price="550" month="MAR" stone="Garnet" image="<?=$img_dir?>PE105-OP.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
<variation price="625" month="APR" stone="Garnet" image="<?=$img_dir?>PE105.png" style="xsdfcSD" gold_color="Yellow" gold_carat="10"/>
</bs>
</data>
Каждый элемент получает блок . (4 предмета)
А вот код от ItemRender:
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="150" height="150" xmlns:local="*">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private var _randomIndex:uint;
private var _indexSet:Boolean;
private function getRandomImage ():String
{
if (!_indexSet)
{
var maxIndex:uint = data.children().length();
_randomIndex = Math.floor(Math.random()*maxIndex);
_indexSet = true;
}
return data.children()[_randomIndex].@image;
}
]]>
</mx:Script>
<local:LoadingImage id="tn" toolTip="{tn.source+'\n\n'+data}" source="{getRandomImage()}" width="150" height="150"/>
</mx:Canvas>
2-й и 3-й показывают изображения, которые находятся только в 4-м блоке.
Кто-нибудь видит то, чего я не вижу?
Спасибо!