2

I would like to bind a variable from my ActionScript to a property of a component that is in a ItemRender. But I always get this error:

1120: Access of undefined property currentRoom.

Here is my code

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:solutionItems="com.barco.components.ControlRoomConfigurator.solutionItems.*">
    <mx:Script>
        <![CDATA[
            import com.barco.VO.ControlRoomConfigurator.Room;

            [Bindable] private var myArrayCollection:ArrayCollection;
            [Bindable] public var currentRoom:Room;


        ]]>
    </mx:Script>
    <mx:List id="listVideoWalls" 
         borderThickness="0"
         dataProvider="{myArrayCollection}" >
        <mx:itemRenderer>
            <mx:Component>
                <solutionItems:displaySolutionItem solutionId="{data.meetsRequirements.getItemAt(currentRoom.id)}" />
            </mx:Component>
        </mx:itemRenderer>
    </mx:List>
</mx:Canvas>

I would like to use the object currentRoom in my ItemRenderer component. How do you do this?

I hope you understand my question.

Thanks!

Vincent

Vinzcent
  • 1,438
  • 6
  • 33
  • 59

2 Answers2

4

The problem is that <mx:Component> definition declares a new scope. So it can't access current mxml file scope directly. <mx:Component> is just a shortcut for prototyping purposes to have a quick draft. But from the scope point of view it is the same as if you extract your component in a separate file. So extract it and stop be confusing :)

Constantiner
  • 14,231
  • 4
  • 27
  • 34
2

One short solution is using outerDocument as

solutionId="{data.meetsRequirements.getItemAt(outerDocument.currentRoom.id)}"

for details read Understanding Flex itemRenderers

Hopes that helps

Imran
  • 2,906
  • 1
  • 19
  • 20