July 24, 2008
For ColdFusion hosting try HostMySite.com. |
Home /
Groups /
Adobe Flex 2
Call function in child pod
(Sorry if this is a frequent question, I tried searching but didn'tScott Brady 04/29/08 10:28 A Short answer:Jeffry Houser 04/29/08 10:57 A Good advice. You can set a creationpolicy on the viewstack too to makeStefan Richter 04/29/08 11:25 A Thanks for all of the advice. I think I'll go the "set bindableScott Brady 04/30/08 09:52 A Hi all,Stefan Richter 05/07/08 02:41 P (Sorry if this is a frequent question, I tried searching but didn't find anything that matched what I'm trying to do) My company's just getting started with Flex and I'm building an app based on the Adobe Dashboard sample app. Basically, we have two tabs. The first tab shows a bunch of bar charts (they're all similar data, with different categories). Two of the charts are going to be clickable -- when you click one, the other tab (the "Details" tab) will show up presenting the data in grid form. The problem I'm having is I need to pass parameters into a function in that details display pod from the main mxml file. I could probably accomplish it by running a function in the main mxml file, but I want all of my pods to be as independent as possible so other future dashboards could also use this pod. Here's basically what I'm doing. Clicking the chart calls this function: ---------------- BEGIN CODE BLOCK ---------------- public function showDetailView():void { var index:Number = 1; StateManager.setViewIndex(index); // Save the view index. viewStack.selectedIndex = index; // If data exists then add the pods. After the pods have been added the data is cleared. var podLayoutManager:PodLayoutManager = podLayoutManagers[index]; if (podDataDictionary[podLayoutManager] != null) addPods(podLayoutManagers[index]); // podLayoutManagers[index].items[0].getDetailData(); } -------------- END CODE BLOCK -------------- It's that last (commented-out) line where I'm trying to find a way to call the function. But, I can't figure out where in the document model that function would be, even after using watch expressions in the debugger. Is it simpler than I'm making it out to be? Or, is there a better way to accomplish the same thing (keeping the pod as independent as possible)? Thanks in advance. Scott Short answer: Define properties (AKA Variables) in the subpod (AKA component). Use parameter passing (potentially with data binding) to send variables from the "main" component into the subcomponent. If you're using a ViewStack, keep in mind that the view probably won't be initialized until it is displayed, and accessing it will probably cause errors. Not sure if this helps. Your code sample is not enough for me to diagnose the problem. Scott Brady wrote: ----- Excess quoted text cut - see Original Post for more ----- -- Jeffry Houser Flex, ColdFusion, AIR AIM: Reboog711 | Phone: 1-203-379-0773 -- Adobe Community Expert <http://www.adobe.com/communities/experts/members/JeffryHouser.html> My Company: <http://www.dot-com-it.com> My Podcast: <http://www.theflexshow.com> My Blog: <http://www.jeffryhouser.com> Good advice. You can set a creationpolicy on the viewstack too to make sure everything gets initted right away. Regards, Stefan On 29 Apr 2008, at 15:57, Jeffry Houser wrote: ----- Excess quoted text cut - see Original Post for more ----- You could consider using an MVC framework like PureMVC. It's ideal if you want to build different loosely coupled components. 'Notifications' are used to communicate amongst the different components. This way they don't need to be aware of the existance of each other. Be careful however with memory leaks (this is especially the case when you add & remove a lot of components from the display list)! Thanks for all of the advice. I think I'll go the "set bindable properties in the subcomponent" route, which seems somewhat safer. -- ----------------------------------------- Scott Brady http://www.scottbrady.net/ Hi all, I have a file uploader for images in Flex. It submits to a CF script which in turn returns an XML tree containing a list of all uploaded files. Yesterday the system stopped working and I tracked it down to a single image which had some strange characters in its filename (they looked foreign, or at least not familiar). The filename of the uploaded image broke my application. I'm sure this is an easy one: is there a CF function or similar I can apply to the image name that would convert any non-conforming characters t something that does not cause problems later on, especially once the filename is included inside an XML structure? Right now this is how I write the XML: <cfxml variable="userXML"> <cfoutput> <brainwave action="#FORM.action#" status="success"> <cfloop query="fetchassets"> <asset id="#id#" type="#assettype#" width="#width#" height="#height#"> <path>#path#</path> </asset> </cfloop> </brainwave> </cfoutput> </cfxml> And here's my upload: <cffile action="upload" filefield="Filedata" destination="#clientdir#" nameconflict="makeunique" /> Be gentle, I am from the Flash/Flex side of the fence so CF is not my mother-tongue. Cheers Stefan
|
Mailing Lists
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||