You can certainly do this with a direct call, but you will be better
served to use an event mechanism.  One issue with direct calls in a
non-trivial app is that you will run into instantiation timing issues.
By default, Flex does not render all UI elements on start-up, but defers
instantiation until the UI area is viewed.  Attempting to access members
of a non-rendered object will raise exceptions.

 

If you have not used the singleton patern for a data model, you really
should take a look.  It is a very clean an reliable way to access and
resond to changes in a data structure.  That, with addEventListener, and
dispatchEvent will give you the most flexible architecture.

 

You will probably have to modify the data model pattern for a dashboard
/pod style app, but connecting your pods via events will give you the
most extensibility.

 

If you really want to make a direct call, describe the dom, maybe we can
help.

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Scott
Sent: Tuesday, April 29, 2008 10:23 AM
To: [email protected]
Subject: [flexcoders] Calling a function in an inner pd

 

(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

 

Reply via email to