FusionWidgets and Flash > Handling Click Events |
You can easily handle the click events for data points on the chart in your Flash movies. That is, whenever a user clicks on a data point e.g., dial, pointer etc., you can be notified of the same in your Flash movie. Here we'll see how to do this. |
Adding link to XML |
To enable your parent movie to track links in FusionWidgets, you need to add S- before every link specified in the XML data document. This instructs the chart to convey the link to its parent SWF movie. An example is given below: <dial id='CPU1' value='49' link='S-parameter'/> Here, S- is the prefix to indicate that this link should be bubbled up to parent SWF. When this link is bubbled up, the specified parameter is passed to the event handler. If you need to pass multiple parameters, one way would be to use a comma to separate each new value. Then String.split the parameter into individual values in the called function. This is a simple method that would only work with string values. |
Listening to events |
To listen to events dispatched by chart, you'll need to construct event listener objects in your code as under: |
// ---------------- Event handlers ---------------------// var objL:Object = new Object(); objL.linkClicked = function(targetObj:Object){ trace("Data belonging to " + targetObj.link + " was clicked"); } |
Here, targetObj.link would contain the link that was specified in the link attribute of the object (after truncating S-). And, you'll also need to register your chart objects with this listener as under: |
//Register the event listeners for charts chartObj.addEventListener("linkClicked", objL); |