2011-02-10 43 views
1

与每次渲染组件时发生的creationComplete类似的呼叫是什么?每次组件渲染时,我都想重新运行一个函数(它必须发出HTTP请求,但每次调用的url都会发生更改),我无法弄清楚如何执行此操作。在组件重新呈现时触发的flex事件?

对于背景:

<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%" 
    creationComplete="loadGallery()"> 

private function loadGallery():void { 
      var src:String = "http://localhost:3000/car_type/" + UserPreference.getInstance().carType.toString() + ".xml"; 
      Alert.show(src); 
      httpService.url = src; 
      httpService.send(); 
     } 

回答

1

我会重写组件的updateDisplayList方法,并在那里添加一个对您的loadGallery方法的调用。

希望有所帮助。

+2

我敢打赌,这将适用于许多情况;但这取决于他想要的功能。我不想将httpService调用包装到updateDisplayList()方法中,因为它们无需更新组件的显示。也有可能组件可能会经历一个渲染事件而不是运行updateDisplayList。例如,如果大小和属性失效,但displayList不是。听取updateComplete方法是我会采取的方法(根据我的回答)。 – JeffryHouser

+0

@Flextras:我更喜欢你的答案:) –

相关问题