Critter’s Code

This is a picture of a bridge and a city. I like bridges and cities. They make me smile.

Jan-15-2008

I need AIR / Actionscript assistance

I have a TileList in my AIR application. Previously, I was including the itemRender directly in the tag like:

<mx:TileList itemRenderer="Timeline" >
<mx:itemRenderer>
   <mx:Component>
    <mx:HBox verticalGap="0" backgroundColor="{outerDocument.checkUser(data.publisher.value)}">
       <mx:Image click="outerDocument.PlaySeesmicVideo(data.flv.value,data.videoUri.value)" />
       <mx:VBox width="100%" height="100%" verticalGap="0" verticalScrollPolicy="off">
       <mx:Label buttonMode="true" width="100%" textAlign="left" />
       <mx:Label text="({data.language.value})" fontSize="9" />
       <mx:Text fontSize="10" text="{outerDocument.StripRE(data.title.value)}"  />
       </mx:VBox>
     </mx:HBox>
   </mx:Component>
</mx:itemRenderer>
</mx:TileList>

I need to move the itemRenderer into it’s own component, but as soon as I do that I get errors on my functions that are fired from within the component. "outerDocument" no longer works.

So, my question, is, how do I reference a function in "main.mxml" from "timeline.mxml" ?

Posted under AIR, ActionScript
  1. Joe Rinehart Said,

    Hey Critter,

    Not trying to be a wiseass, but you shouldn’t reference a function in main.mxml from an itemRenderer instance (Timeline).

    If you’re in an MVC setup, your view (Timeline) can interact with a controller, letting it dispatch an event or otherwise handle an interaction that the main app will respond to.

    If you’re not building out such a system, I’d look into having your Timeline item renderer implement IDropInListItemRenderer, which’ll at least give it a way to “reach” the containing TileList. It violates encapsulation completely, but you can in turn use a property on the TileList to get to the containing document.

    Maybe if you describe what the function in main does and the situation I can help more?

  2. Critter Said,

    Hey Joe.. No, I don’t think you are being a wiseass… I am new to this.. so whatever advise you can offer is good for me..

    basically the timeline is populated and displays an image,author,time of post, language. and path to flv

    so clicking on the image.. will open up a window that has a VideoDisplay on it.. and will have, obviously, the flv passed to it and a few other bits of information for display.

    I had tried to fire the function from timeline.mxml, but it kept opening up more than one video window… but creating the window on “creationComplete” was fired off for every item in the tilelist..

    simeon was able to show me how to broadcast a message from the tilelist component back to main.mxml, but I am curious to know if I should handle it a different way…

Add A Comment

« Back to text comment