Sign in to follow this  
kappuz

Is there an onLoad event to know when the graph finished rendering?

Recommended Posts

I want to know if something like this exists (for attaching actions when the graph finished rendering):

 

 

 

 

 

theGraph.onFinishedRender = function afterRender() {

 

 

 

//Make actions when the graph has been rendered

 

 

 

}

 

 

 

theGraph.render();

 

 

 

 

 

Thanks!

Share this post


Link to post
Share on other sites

Then it is impossible to know when the graph finished rendering?.... is there any property I can check to know if it has finished rendering?....

 

 

 

 

 

I hope there is something.....

Share this post


Link to post
Share on other sites

For each chart, it differs.

render() is the consolidated chart method that calls all the chart methods in a sequence at the given time interval (based on animation pattern). We use setInterval and clearInterval to call these methods at the required time interval. So, even the event would need to be called as a part of the last function in the sequence of that chart.

Share this post


Link to post
Share on other sites

I too need to know how to determine when a chart has finished rendering.

 

 

 

I need this because I have a flash movie where a user can choose a chart-type to show a particular set of data. At present, switching between chart types too quickly causes conficts and weird draw problems even though I am removing the old chart movieclip or using the destroy method and then re-creating a new chart.

 

 

 

If I could test when the render has finished I could disable switching chart type until the chart is finished rendering.

 

 

 

 

 

 

 

ade.

Share this post


Link to post
Share on other sites

I have a solution to your problem. :cool:

 

 

 

I started by trying to predict when the chart would be rendered with the undocumented flash function setTimeout, but realized that this would lead to many problems down the road. Unknowns like HTTP XML loading, server load and response times, client CPU, and other variables are out of your control.

 

 

 

I would recommend using setInterval approach to check to see if a known movie clip has been rendered.

 

 

 

This is how I accomplished running something after render was complete:

 

 

 




// Due to the fact that Flash has a horrible XPath implementation,

// I am using X Factor Studio's very nice XPath class.  Highly recommended.

// http://xfactorstudio.com



function setHandlers(){

// set handlers for Anchor points

var datasets:Array = XPath.selectNodes(dataSet.firstChild, '/chart/dataset');

for(var i:Number = 1; i <= datasets.length; i++){

	var set_arr:Array = XPath.selectNodes(datasets[i - 1], 'set');

	for(var j:Number = 1; j <= set_arr.length; j++){

		trace("_level0.ChartHolder_0.Chart.Anchor_"+i+"_"+j);

		_level0.ChartHolder_0.Chart["Anchor_"+i+"_"+j].onRollOver = function(){

			trace("You just rolled over me: "+this._name);

		}

	}

}

}



function isRendered(){

// Goal: test if XML is loaded.

//         test if last Anchor point has been added to the Chart

trace("isRendered called");

if(dataSet.loaded){

	// get the array of datasets from our XML

	var sets:Array = XPath.selectNodes(dataSet.firstChild, '/chart/dataset');

	// get the last dataset's set nodes

	var lastSet:Array = XPath.selectNodes(dataSet.firstChild, '/chart/dataset[last()]/set');

	// I will test to see if the last expected Anchor has been drawn

	// example _level0.ChartHolder_0.Chart.Anchor_1_12

	if(_level0.ChartHolder_0.Chart["Anchor_"+(sets.length)+"_"+(lastSet.length)] != undefined){

		clearInterval(my_interval); // clear the interval isRendered test

		setHandlers();

	}

}

}



var my_interval:Number = setInterval(isRendered, 250); // test isRendered every 1/4 second



Edited by Guest

Share this post


Link to post
Share on other sites
Guest epoch1

[email protected]

 

 

 

 

 

 

 

hi

 

>is it possible to show anchor on area chart

 

>i done this

 

>but i want to ask that is it possible to show anchor on some part means

 

>on first value i want to show anchor and on second i not want to show

 

>anchor

 

>nitin

 

 

 

 

 

 

 

Hi

 

Thanks for this

 

can u pls tell me wat is the error

 

i also sending the action script file

 

sir my problem is i not want to show some anchor on some part can u tell me how can i do this

 

 

 

nitin

 

9892516802

 

 

 

this is my xml

 

 

 

 

 

http://www.google.com' hoverText='nitin' anchorAlpha='50'/>

 

http://www.google.com' hoverText='nitin' drawAnchors='0' anchorAlpha='0'/>

 

http://www.google.com' hoverText='nitin' anchorAlpha='0' drawAnchors='0'/>

 

http://www.google.com' hoverText='nitin' anchorAlpha='5' drawAnchors='0'/>

 

http://www.google.com' drawAnchors='0'/>

 

 

 

Share this post


Link to post
Share on other sites
Guest epoch1

[email protected]

 

 

 

 

 

 

 

hi

 

>is it possible to show anchor on area chart

 

>i done this

 

>but i want to ask that is it possible to show anchor on some part means

 

>on first value i want to show anchor and on second i not want to show

 

>anchor

 

>nitin

 

 

 

 

 

 

 

Hi

 

Thanks for this

 

can u pls tell me wat is the error

 

i also sending the action script file

 

sir my problem is i not want to show some anchor on some part can u tell me how can i do this

 

 

 

nitin

 

9892516802

 

 

 

this is my xml

 

 

 

 

 

http://www.google.com' hoverText='nitin' anchorAlpha='50'/>

 

http://www.google.com' hoverText='nitin' drawAnchors='0' anchorAlpha='0'/>

 

http://www.google.com' hoverText='nitin' anchorAlpha='0' drawAnchors='0'/>

 

http://www.google.com' hoverText='nitin' anchorAlpha='5' drawAnchors='0'/>

 

http://www.google.com' drawAnchors='0'/>

 

 

 

Share this post


Link to post
Share on other sites
Guest epoch1

[email protected]

 

 

 

 

 

 

 

hi

 

>is it possible to show anchor on area chart

 

>i done this

 

>but i want to ask that is it possible to show anchor on some part means

 

>on first value i want to show anchor and on second i not want to show

 

>anchor

 

>nitin

 

 

 

 

 

 

 

Hi

 

Thanks for this

 

can u pls tell me wat is the error

 

i also sending the action script file

 

sir my problem is i not want to show some anchor on some part can u tell me how can i do this

 

 

 

nitin

 

9892516802

 

 

 

this is my xml

 

 

 

 

 

http://www.google.com' hoverText='nitin' anchorAlpha='50'/>

 

http://www.google.com' hoverText='nitin' drawAnchors='0' anchorAlpha='0'/>

 

http://www.google.com' hoverText='nitin' anchorAlpha='0' drawAnchors='0'/>

 

http://www.google.com' hoverText='nitin' anchorAlpha='5' drawAnchors='0'/>

 

http://www.google.com' drawAnchors='0'/>

 

 

 

Share this post


Link to post
Share on other sites
mr_interweb (3/27/2007)
I have a solution to your problem. :cool:

 

 

 

I started by trying to predict when the chart would be rendered with the undocumented flash function setTimeout, but realized that this would lead to many problems down the road. Unknowns like HTTP XML loading, server load and response times, client CPU, and other variables are out of your control.

 

 

 

I would recommend using setInterval approach to check to see if a known movie clip has been rendered.

 

 

 

This is how I accomplished running something after render was complete:

 

 

 




// Due to the fact that Flash has a horrible XPath implementation,

// I am using X Factor Studio's very nice XPath class.  Highly recommended.

// http://xfactorstudio.com



function setHandlers(){

// set handlers for Anchor points

var datasets:Array = XPath.selectNodes(dataSet.firstChild, '/chart/dataset');

for(var i:Number = 1; i <= datasets.length; i++){

	var set_arr:Array = XPath.selectNodes(datasets[i - 1], 'set');

	for(var j:Number = 1; j <= set_arr.length; j++){

		trace("_level0.ChartHolder_0.Chart.Anchor_"+i+"_"+j);

		_level0.ChartHolder_0.Chart["Anchor_"+i+"_"+j].onRollOver = function(){

			trace("You just rolled over me: "+this._name);

		}

	}

}

}



function isRendered(){

// Goal: test if XML is loaded.

//         test if last Anchor point has been added to the Chart

trace("isRendered called");

if(dataSet.loaded){

	// get the array of datasets from our XML

	var sets:Array = XPath.selectNodes(dataSet.firstChild, '/chart/dataset');

	// get the last dataset's set nodes

	var lastSet:Array = XPath.selectNodes(dataSet.firstChild, '/chart/dataset[last()]/set');

	// I will test to see if the last expected Anchor has been drawn

	// example _level0.ChartHolder_0.Chart.Anchor_1_12

	if(_level0.ChartHolder_0.Chart["Anchor_"+(sets.length)+"_"+(lastSet.length)] != undefined){

		clearInterval(my_interval); // clear the interval isRendered test

		setHandlers();

	}

}

}



var my_interval:Number = setInterval(isRendered, 250); // test isRendered every 1/4 second



 

 

 

 

Hi, I think this is very useful, but can I know in detail how to use this? like where should I place those code?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this