Search code examples
variablesactionscriptflex4itemrenderer

pass extra variable in an itemRenderer


i have a List which uses a an arrayCollection as dataprovider and an itemRenderer to display some things but how can i pass an extra variable to this itemRenderer?? Any help?

for example here: adobe flex examples what if i want to pass an extra variable to declare what is the folder name where the image can be found?

Thanks beforehand!


Solution

  • Use a ClassFactory:

    [Bindable]
    protected var cf:ClassFactory;//bind your List's itemRenderer property to this
    
    protected function onPreInitialize():void {
       cf = new ClassFactory(YourRenderer);
       //note that {folder='theFolder'} is now {folder:'theFolder'}
       cf.properties = {folder:'theFolder'};//note that your renderer will need to expose a public folder property
    }