[flexcoders] appending to a dataprovider in actionscript
I am still trying to iron out the problems with data binding in actionscript an server push. If I just replace the old array with a new one, it updates ok, but when I append to an array, it doesn't seem to work. I have to do everything in actionscript. I set up the data binding like this. BindingUtils.bindProperty(lineSeries, dataProvider, ser, pointList); Here is the way I'm currently trying to append the new data and catch the error, but this does not work. // oldArray is the same as pointlist from the data binding line of code above for (var i:int = 0; inewArray.length; i++) { oldArray.addItem(newArray.getItemAt(i)); } What's more, because the app is fired remotedly from a server process, I can't trace or run it in debug mode to find out why it's failing. Usually, I'll throw in an Alert.show to find out if the data is messed up or a variable is null, but when I do it after running this loop, the Alert just hangs the whole application. Is there anyway to throw an error to a popup box (flash seems to do this from time to time on its own) And one final related question. If I do get the new arrays to work, will the charts labels and range adjust accordingly. In other words, if the original array was from Mon-Wed, if the new data is on Thurs, will the chart auto adjust properly to show the new data?
RE: [flexcoders] appending to a dataprovider in actionscript
Use trace() to debug instead of Alert. Using Alert can cause UI/focus problems in some circumstances. Also, have you tried using ChangeWatcher instead of bindProperty? It might be easier to debug, since you can verify if/when the handler is called. In the handler, directly assign the dataProvider property. Using addItem() *should* cause the necessary events to be dispatched. BTW, you are using an ArrayCollection, not an Array. There is a significant difference. Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of netdeep Sent: Thursday, November 20, 2008 1:42 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] appending to a dataprovider in actionscript I am still trying to iron out the problems with data binding in actionscript an server push. If I just replace the old array with a new one, it updates ok, but when I append to an array, it doesn't seem to work. I have to do everything in actionscript. I set up the data binding like this. BindingUtils.bindProperty(lineSeries, dataProvider, ser, pointList); Here is the way I'm currently trying to append the new data and catch the error, but this does not work. // oldArray is the same as pointlist from the data binding line of code above for (var i:int = 0; inewArray.length; i++) { oldArray.addItem(newArray.getItemAt(i)); } What's more, because the app is fired remotedly from a server process, I can't trace or run it in debug mode to find out why it's failing. Usually, I'll throw in an Alert.show to find out if the data is messed up or a variable is null, but when I do it after running this loop, the Alert just hangs the whole application. Is there anyway to throw an error to a popup box (flash seems to do this from time to time on its own) And one final related question. If I do get the new arrays to work, will the charts labels and range adjust accordingly. In other words, if the original array was from Mon-Wed, if the new data is on Thurs, will the chart auto adjust properly to show the new data?
Re: [flexcoders] appending to a dataprovider in actionscript
A quick solution would probablt be to receive the new data, clone the old array, append the new data to the cloned array and reasign the bound array to the clonned array (It might not be the best solution but I have noticed that the easiest way to solve bonding problems is to reasign the array...) On Thu, Nov 20, 2008 at 11:25 PM, Tracy Spratt [EMAIL PROTECTED]wrote: Use trace() to debug instead of Alert. Using Alert can cause UI/focus problems in some circumstances. Also, have you tried using ChangeWatcher instead of bindProperty? It might be easier to debug, since you can verify if/when the handler is called. In the handler, directly assign the dataProvider property. Using addItem() **should** cause the necessary events to be dispatched. BTW, you are using an ArrayCollection, not an Array. There is a significant difference. Tracy -- *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *netdeep *Sent:* Thursday, November 20, 2008 1:42 PM *To:* flexcoders@yahoogroups.com *Subject:* [flexcoders] appending to a dataprovider in actionscript I am still trying to iron out the problems with data binding in actionscript an server push. If I just replace the old array with a new one, it updates ok, but when I append to an array, it doesn't seem to work. I have to do everything in actionscript. I set up the data binding like this. BindingUtils.bindProperty(lineSeries, dataProvider, ser, pointList); Here is the way I'm currently trying to append the new data and catch the error, but this does not work. // oldArray is the same as pointlist from the data binding line of code above for (var i:int = 0; inewArray.length; i++) { oldArray.addItem(newArray.getItemAt(i)); } What's more, because the app is fired remotedly from a server process, I can't trace or run it in debug mode to find out why it's failing. Usually, I'll throw in an Alert.show to find out if the data is messed up or a variable is null, but when I do it after running this loop, the Alert just hangs the whole application. Is there anyway to throw an error to a popup box (flash seems to do this from time to time on its own) And one final related question. If I do get the new arrays to work, will the charts labels and range adjust accordingly. In other words, if the original array was from Mon-Wed, if the new data is on Thurs, will the chart auto adjust properly to show the new data? -- Fotis Chatzinikos, Ph.D. Founder, Phinnovation [EMAIL PROTECTED],
Re: [flexcoders] appending to a dataprovider in actionscript
if u want to listen a ArrayCollection when some of its elements are changed. u could write like this: dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE,updateHandler); private function updateHandler(event:CollectionEvent):void { } look up CollectionEvent api , u can find out how to do next step. From: netdeep [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Friday, November 21, 2008 2:41:48 AM Subject: [flexcoders] appending to a dataprovider in actionscript I am still trying to iron out the problems with data binding in actionscript an server push. If I just replace the old array with a new one, it updates ok, but when I append to an array, it doesn't seem to work. I have to do everything in actionscript. I set up the data binding like this. BindingUtils. bindProperty( lineSeries, dataProvider , ser, pointList) ; Here is the way I'm currently trying to append the new data and catch the error, but this does not work. // oldArray is the same as pointlist from the data binding line of code above for (var i:int = 0; inewArray.length; i++) { oldArray.addItem( newArray. getItemAt( i)); } What's more, because the app is fired remotedly from a server process, I can't trace or run it in debug mode to find out why it's failing. Usually, I'll throw in an Alert.show to find out if the data is messed up or a variable is null, but when I do it after running this loop, the Alert just hangs the whole application. Is there anyway to throw an error to a popup box (flash seems to do this from time to time on its own) And one final related question. If I do get the new arrays to work, will the charts labels and range adjust accordingly. In other words, if the original array was from Mon-Wed, if the new data is on Thurs, will the chart auto adjust properly to show the new data?