You can't do complex assignments outside of a function, because of the
way the mxml is compiled into the as class.

 

Override the set data() function and store your data in a local var,
then call invalidateProperties().

 

Then do your work in a commitProperties override.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of pioplacz
Sent: Sunday, June 15, 2008 7:07 AM
To: [email protected]
Subject: [flexcoders] Re: Split up data inside itemrenderer

 

Here is my main mxml file:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " height="100%" 
layout="absolute" 
creationComplete="startupServices()" xmlns:lib="flexlib.containers.*" 
styleName="ListItems" xmlns:view="view.*" verticalGap="0">
<!-- Call the XML list with the waiting folders -->
<mx:HTTPService id="getWaitingItems" 
url="http://192.168.1.197/PHP/adminFolders/getFolders.php
<http://192.168.1.197/PHP/adminFolders/getFolders.php> " method="GET" 
useProxy="false" result="waitingItems_results(event)"/>
<!-- Calling the IMDB for results -->
<mx:HTTPService id="IMDBSearch" 
url="http://192.168.1.197/PHP/adminFolders/imdbphp-1.0.3/imdbXMLsearch.p
hp
<http://192.168.1.197/PHP/adminFolders/imdbphp-1.0.3/imdbXMLsearch.php>
" 
method="GET" result="imdbSearch_results(event)">
<mx:request>
<!--<name>{SearchBox.text}</name>
<searchtype>movie</searchtype> --> 
</mx:request>
</mx:HTTPService>
<!-- Getting the IMDB item details -->
<mx:HTTPService id="IMDBDetails" 
url="http://192.168.1.197/PHP/adminFolders/imdbphp-1.0.3/imdbXML.php
<http://192.168.1.197/PHP/adminFolders/imdbphp-1.0.3/imdbXML.php> " 
method="GET" result="imdbDetails(event)">
<mx:request xmlns="">
<!--<mid>{imdbList.selectedItem.imdbid}</mid>-->
</mx:request>
</mx:HTTPService>
<mx:Style source="css/whiteTheme.css"/>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.collections.IList; 
import mx.utils.ArrayUtil;

public function startupServices():void {
getWaitingItems.send();
}

public function waitingItems_results(event:ResultEvent):void
{
waitingItems = event.result.allWaiting.folder as ArrayCollection;
}

[Bindable]
private var waitingItems:ArrayCollection;

public function imdbSearch_results(event:ResultEvent):void
{
imdbSearch = event.result.IMDBresult.movie as ArrayCollection;
}

[Bindable]
private var imdbSearch:ArrayCollection;

[Bindable]
public var imdbPlots:ArrayCollection;
public var newPlotsArray:Array; 

public function imdbDetails(event:ResultEvent):void
{
// First determine if the result can be converted or present itself as
an 
array. 
// We can use the mx.collections.ILis interface for that 
if (IMDBDetails.lastResult.IMDBdata.movie.plots.plot is IList) 
{ 
// when true, call the IList.toArray() method 
newPlotsArray = 
IMDBDetails.lastResult.IMDBdata.movie.plots.plot.toArray(); 
} else{ 
// when false, use the ArrayUtil.toArray() method to convert the result 
newPlotsArray = 
ArrayUtil.toArray(IMDBDetails.lastResult.IMDBdata.movie.plots.plot); 
} 
// Create a new ArrayCollection using 'newArray' 
imdbPlots = new ArrayCollection(newPlotsArray); 
}

]]>
</mx:Script>
<mx:VBox width="960" height="100%" horizontalCenter="0" top="0" 
verticalGap="0">
<mx:Spacer height="59"/>
<mx:HBox width="100%">
<mx:Spacer width="100%"/>
<mx:Label text="You have 4 items in query" x="828" y="10"/>
</mx:HBox>
<mx:HRule width="100%" strokeWidth="1" strokeColor="#C4C4C4"/>
<mx:Spacer height="22"/>
<mx:TabNavigator id="tn" width="100%" height="90%" tabWidth="140">
<view:moviesView label="Movies" width="100%" height="100%"/>
<mx:VBox label="TV-Shows" enabled="false"/>
<mx:VBox label="Maintance" enabled="false"/>
</mx:TabNavigator> 
<mx:Canvas width="100%">
<mx:Text text="TEST" textAlign="center" horizontalCenter="0" top="10" 
color="#595959"/>
</mx:Canvas>
</mx:VBox> 
</mx:Application>

Here is my itemrenderer for mx:List:

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " width="925" height="74">
<mx:Script>
<![CDATA[
//I keep on getting the error here. 
var queryStr:String = data.stars;
var params:Array = queryStr.split(",");
]]>
</mx:Script>
<mx:Style source="../css/whiteTheme.css"/>
<mx:states>
<mx:State name="moreInfo">
<mx:SetProperty name="height" value="250"/>
<mx:AddChild relativeTo="{mainCanvas}" position="lastChild">
<mx:HRule x="57" y="67" strokeWidth="1" 
strokeColor="#E3E3E3" width="860"/>
</mx:AddChild>
<mx:AddChild relativeTo="{mainCanvas}" position="lastChild">
<mx:HBox x="57" y="72" height="166" 
horizontalAlign="right" width="860" horizontalGap="15">
<mx:VBox verticalGap="0">
<mx:Label x="57" y="72" 
text="Director:" color="#000000"/>
<mx:Text text="{data.director}" 
color="#343434" height="15"/>
<mx:Spacer height="2"/>
<mx:Label text="Writers:" 
color="#000000" height="17"/>
<mx:Text text="n/a" 
color="#343434" height="15"/>
</mx:VBox>
<mx:VBox verticalGap="0">
<mx:Label text="Actors:" 
color="#000000" height="17"/>
<mx:Repeater id="myrep" 
dataProvider="{data.actors.actor}">
<mx:Text 
text="{myrep.currentItem}" color="#343434" height="15"/>
</mx:Repeater>
</mx:VBox>
<mx:VBox verticalGap="0" height="100%" 
width="100%">
<mx:Label x="57" y="72" text="Plot 
Summary:" color="#000000" fontWeight="normal"/>
<mx:TextArea 
text="{data.description}" color="#343434" borderStyle="none"
height="90%" 
editable="false" width="100%"/>
<mx:Spacer height="15"/>
</mx:VBox>
<mx:VBox verticalGap="0">
<mx:Label x="57" y="72" 
text="Runtime:" color="#000000"/>
<mx:Text text="{data.duration} 
minutes" color="#343434" height="15"/>
<mx:Spacer height="2"/>
<mx:Label text="Studios:" 
color="#000000" height="17"/>
<mx:Text text="{data.publisher}" 
color="#343434" height="15"/>
<mx:Spacer height="2"/>
<mx:Label text="IMDB id:" 
color="#000000" height="17"/>
<mx:Text text="n/a" 
color="#343434" height="15"/>
<mx:Spacer height="2"/>
<mx:Label text="ASIN:" 
color="#000000" height="17"/>
<mx:Text text="n/a" 
color="#343434" height="15"/>
</mx:VBox>
<mx:VBox width="85" verticalGap="0">
<mx:Label x="57" y="72" 
text="IMDB Rating:" color="#000000"/>
<mx:Text text="n/a&#xd;" 
color="#343434" height="15"/>
<mx:Spacer height="2"/>
<mx:Label text="IMDB Votes:" 
color="#000000" height="17"/>
<mx:Text text="n/a&#xd;" 
color="#343434" height="15"/>
<mx:Spacer height="2"/>
<mx:Label text="Amazon Rating:" 
color="#000000" height="17"/>
<mx:Text text="{data.rating}/5" 
color="#343434" height="15"/>
<mx:Spacer height="2"/>
<mx:Label text="Amazon Votes:" 
color="#000000" height="17"/>
<mx:Text text="n/a" 
color="#343434" height="15"/>
</mx:VBox>
</mx:HBox>
</mx:AddChild>
</mx:State>
</mx:states>
<mx:Canvas width="925" height="100%" styleName="ListItems" 
id="mainCanvas">
<mx:Image width="45" height="64" x="4" y="4" 
source="assets/movieBox.png"/>
<mx:Canvas top="2">
<mx:Label x="55" y="10" text="{data.title} ({data.year})" 
styleName="title"/>
<mx:HRule x="57" y="33" width="860" strokeColor="#E3E3E3" 
strokeWidth="1" id="hrule"/>
<mx:Button x="854" y="5" click="currentState='moreInfo'" 
id="editButton" width="63" height="25" styleName="editButton"/> 
<mx:Button x="845" y="37" click="currentState='moreInfo'" 
id="deleteButton" width="73" height="25" styleName="deleteButton"/>
<mx:Image x="56" y="36" 
source="assets/rating/rating_{data.rating}.png" width="41" height="8"/>
<mx:Text x="55" y="44" text="{data.genres}" width="187" 
textAlign="left" color="#595959" selectable="false" id="movieGenres"/>
</mx:Canvas>
</mx:Canvas>
</mx:Canvas>

I know that it's just some stupid error, but I'm going crazy. 

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "donvoltz" <[EMAIL PROTECTED]> wrote:
>
> Could you provide more of the code you are using so we can see what
> you are doing.
> 
> Don
>

 

Reply via email to