[Flashcoders] AIR Socket.readObject received in multiple ProgressEvents?
In a the client of a client/server AIR app I have: function onSocketData(event:ProgressEvent) : void { var result = _socket.readObject(); // do something with result } How can I be sure the whole object is available before I try to use it? Things work as expected most of the time, but with large pieces of data or on laptops will hang when operating over a wireless connection, so I suspect the object is spread out over multiple ProgressEvents. I can only find pseudo code illustrating what you should do reassemble an AMF object received in separate ProgressEvents. _ _ _ Erik Mattheis | Weber Shandwick P: (952) 346.6610 M: (612) 377.2272 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AIR Socket.readObject received in multiple ProgressEvents?
Hi, Are you sure that this is not something server-side? I have had similar problems which were compounded when using Wireless connections - we traced the fault back to the server code giving up filling the socket buffer when it got a buffer full event? Apart from that you could use some sort of paradigm like: http://stackoverflow.com/questions/7345214/as3-air-readobject-from-socket-how-do-you-check-all-data-has-been-received Glen On 15/02/2012 16:44, Mattheis, Erik (MIN-WSW) wrote: In a the client of a client/server AIR app I have: function onSocketData(event:ProgressEvent) : void { var result = _socket.readObject(); // do something with result } How can I be sure the whole object is available before I try to use it? Things work as expected most of the time, but with large pieces of data or on laptops will hang when operating over a wireless connection, so I suspect the object is spread out over multiple ProgressEvents. I can only find pseudo code illustrating what you should do reassemble an AMF object received in separate ProgressEvents. _ _ _ Erik Mattheis | Weber Shandwick P: (952) 346.6610 M: (612) 377.2272 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AIR Socket.readObject received in multiple ProgressEvents?
Basic TCP rules says that you are sending an octet stream. All socket APIs are optimized for bulk access to avoid silly performance issues due to lots of function calls (and possible mode switches). This means that you MAY get more than one object in one go and that you MAY get only a part of the object(s) at the ends of the buffer. You need to separate data manually. You have three strategies: * Fixed size (easy, not flexible) * Terminator (slightly tricky with buffers, flexible, possible escaping issues, slight overhead) * Transmitted size (easy with buffers, flexible, slight overhead) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] MVC style
Hello list, If I am making an application with MVC pattern and calculations are needed to be performed on the data when the user interacts with the application, would you: do the calculations in the Model? create a separate class that handles the calculations and puts the results in the model? do the calculations in the Controller? looking forward to hearing people's thoughts on this, david -- David Hunter www.davidhunterdesign.com +44 (0) 7869 104 906 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] MVC style
Calculations would not be in the controller, they would be in the Model. Sometimes you can justify them being in the view if it's related to the view. Calculations are also in a Service class if they are part of a service in some way. Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of David Hunter Sent: Wednesday, February 15, 2012 1:32 PM To: Flash Coders List Subject: [Flashcoders] MVC style Hello list, If I am making an application with MVC pattern and calculations are needed to be performed on the data when the user interacts with the application, would you: do the calculations in the Model? create a separate class that handles the calculations and puts the results in the model? do the calculations in the Controller? looking forward to hearing people's thoughts on this, david -- David Hunter www.davidhunterdesign.com +44 (0) 7869 104 906 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses. References to Sender are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link: http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you consent to the foregoing. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AIR Socket.readObject received in multiple ProgressEvents?
I've not considered it may be a server issue. The server is also an AIR app - looking at the documentation there doesn't seem to be any events related to sending data over sockets - is it possible to tell if data was successfully written to the socket? On 2/15/12 11:29 AM, Glen Pike g...@engineeredarts.co.uk wrote: Are you sure that this is not something server-side? I have had similar problems which were compounded when using Wireless connections - we traced the fault back to the server code giving up filling the socket buffer when it got a buffer full event? Apart from that you could use some sort of paradigm like: http://stackoverflow.com/questions/7345214/as3-air-readobject-from-socket-how-do-you-check-all-data-has-been-received Glen _ _ _ Erik Mattheis | Weber Shandwick P: (952) 346.6610 M: (612) 377.2272 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AIR Socket.readObject received in multiple ProgressEvents?
I've been unsuccessful at finding an example of a functional AS app which uses one of the second two approaches, I can only find broad descriptions of what needs to happen. It appears that Socket.bytesAvailable functions differently depending on the version of AIR, either representing the number of bytes which haven't yet been read or the cumulative total of bytes sent over the socket. If I have to do this without looking at functional examples, how would one transmit a terminator byte or byte size while using Socket.writeObject()? Perhaps the reason I can't find examples is it's not even a good idea to try? The problem I'm trying to solve is to transmit an instance of a class like this from the server app and reassemble it on the client: package mn.webershandwick.firebell.data { import fl.data.DataProvider; public class SiteVO extends Object { public var siteId:String; public var posts:Array; public var profilesDataProvider:DataProvider; public function SiteVO() {} } } Socket.writeObject and Socket.readObject does everything for me but fails consistently when the amount of data held in the variables is large and intermittently at any size over a wireless connection. On 2/15/12 11:41 AM, Henrik Andersson he...@henke37.cjb.net wrote: You need to separate data manually. You have three strategies: * Fixed size (easy, not flexible) * Terminator (slightly tricky with buffers, flexible, possible escaping issues, slight overhead) * Transmitted size (easy with buffers, flexible, slight overhead) _ _ _ Erik Mattheis | Weber Shandwick P: (952) 346.6610 M: (612) 377.2272 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AIR Socket.readObject received in multiple ProgressEvents?
Mattheis, Erik (MIN-WSW) skriver: If I have to do this without looking at functional examples, how would one transmit a terminator byte or byte size while using Socket.writeObject()? Write the object to a ByteArray, measure the size of that and send the size of that before the contents of the ByteArray. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] am i loaded by another swf?
Hey List, I'm building a swf, and i want to set the stage.scaleMode and align ONLY IF my swf is the top level swf, and was not loaded by another swf. anyone know how to find out if a swf was loaded by another swf? need more info? thanks -- Ktu; The information contained in this message may or may not be privileged and/or confidential. If you are NOT the intended recipient, congratulations, you got mail! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] am i loaded by another swf?
Hi, Can you check if the parent exists, and is there a way to determine if this is the document/main class? Glen Sent from my HTC - Reply message - From: Ktu ktu_fl...@cataclysmicrewind.com To: Flash Coders flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] am i loaded by another swf? Date: Wed, Feb 15, 2012 19:55 Hey List, I'm building a swf, and i want to set the stage.scaleMode and align ONLY IF my swf is the top level swf, and was not loaded by another swf. anyone know how to find out if a swf was loaded by another swf? need more info? thanks -- Ktu; The information contained in this message may or may not be privileged and/or confidential. If you are NOT the intended recipient, congratulations, you got mail! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] am i loaded by another swf?
Ktu skriver: Hey List, I'm building a swf, and i want to set the stage.scaleMode and align ONLY IF my swf is the top level swf, and was not loaded by another swf. anyone know how to find out if a swf was loaded by another swf? need more info? thanks You can't know in the general case, but here is a good enough guess: function isFirstMovie():Boolean { return stage root==stage.getChildAt(1); } There is however one specific case where you can know: During the construction of the first frame (that includes the document class constructor). Check if you are on the stage during that. Only the first loaded movie will be, any subsequently loaded movies will not be. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] am i loaded by another swf?
so I could do something like this: public function Main():void { if (stage) { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; init(); } else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener (Event.ADDED_TO_STAGE, init); // entry point } ? On Wed, Feb 15, 2012 at 3:07 PM, Henrik Andersson he...@henke37.cjb.netwrote: Ktu skriver: Hey List, I'm building a swf, and i want to set the stage.scaleMode and align ONLY IF my swf is the top level swf, and was not loaded by another swf. anyone know how to find out if a swf was loaded by another swf? need more info? thanks You can't know in the general case, but here is a good enough guess: function isFirstMovie():Boolean { return stage root==stage.getChildAt(1); } There is however one specific case where you can know: During the construction of the first frame (that includes the document class constructor). Check if you are on the stage during that. Only the first loaded movie will be, any subsequently loaded movies will not be. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Ktu; The information contained in this message may or may not be privileged and/or confidential. If you are NOT the intended recipient, congratulations, you got mail! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] am i loaded by another swf?
sorry now, what if the loader is already in a display list when it runs that first frame? is it still not aware of the stage? On Wed, Feb 15, 2012 at 3:33 PM, Ktu ktu_fl...@cataclysmicrewind.comwrote: so I could do something like this: public function Main():void { if (stage) { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; init(); } else addEventListener(Event.ADDED_TO_STAGE, init); } private function init(e:Event = null):void { removeEventListener (Event.ADDED_TO_STAGE, init); // entry point } ? On Wed, Feb 15, 2012 at 3:07 PM, Henrik Andersson he...@henke37.cjb.netwrote: Ktu skriver: Hey List, I'm building a swf, and i want to set the stage.scaleMode and align ONLY IF my swf is the top level swf, and was not loaded by another swf. anyone know how to find out if a swf was loaded by another swf? need more info? thanks You can't know in the general case, but here is a good enough guess: function isFirstMovie():Boolean { return stage root==stage.getChildAt(1); } There is however one specific case where you can know: During the construction of the first frame (that includes the document class constructor). Check if you are on the stage during that. Only the first loaded movie will be, any subsequently loaded movies will not be. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Ktu; The information contained in this message may or may not be privileged and/or confidential. If you are NOT the intended recipient, congratulations, you got mail! -- Ktu; The information contained in this message may or may not be privileged and/or confidential. If you are NOT the intended recipient, congratulations, you got mail! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] am i loaded by another swf?
Ktu skriver: sorry now, what if the loader is already in a display list when it runs that first frame? is it still not aware of the stage? If a movie is loaded by a Loader that is on the display tree of the stage the loaded movie DOES NOT have access to the stage. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] am i loaded by another swf?
I think that if a SWF is loaded by another SWF (e.g. using SWFLoader), 'stage' will be null. -Gerry On 2012-02-16 , at 04:07 , g...@engineeredarts.co.uk wrote: Hi, Can you check if the parent exists, and is there a way to determine if this is the document/main class? Glen Sent from my HTC - Reply message - From: Ktu ktu_fl...@cataclysmicrewind.com To: Flash Coders flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] am i loaded by another swf? Date: Wed, Feb 15, 2012 19:55 Hey List, I'm building a swf, and i want to set the stage.scaleMode and align ONLY IF my swf is the top level swf, and was not loaded by another swf. anyone know how to find out if a swf was loaded by another swf? need more info? thanks -- Ktu; The information contained in this message may or may not be privileged and/or confidential. If you are NOT the intended recipient, congratulations, you got mail! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] am i loaded by another swf?
Is there no reference in AS3 like AS2 where you can look with _level0 for the top level MC? Best, Karl On Feb 15, 2012, at 4:13 PM, Gerry Beauregard wrote: I think that if a SWF is loaded by another SWF (e.g. using SWFLoader), 'stage' will be null. -Gerry On 2012-02-16 , at 04:07 , g...@engineeredarts.co.uk wrote: Hi, Can you check if the parent exists, and is there a way to determine if this is the document/main class? Glen Sent from my HTC - Reply message - From: Ktu ktu_fl...@cataclysmicrewind.com To: Flash Coders flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] am i loaded by another swf? Date: Wed, Feb 15, 2012 19:55 Hey List, I'm building a swf, and i want to set the stage.scaleMode and align ONLY IF my swf is the top level swf, and was not loaded by another swf. anyone know how to find out if a swf was loaded by another swf? need more info? thanks -- Ktu; The information contained in this message may or may not be privileged and/or confidential. If you are NOT the intended recipient, congratulations, you got mail! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] am i loaded by another swf?
Karl DeSaulniers skriver: Is there no reference in AS3 like AS2 where you can look with _level0 for the top level MC? The equivalent to levels would be the display list of the stage itself. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] MVC style
I am an MVC purist, I always proceed as follows: Models should ONLY store information, particularly the state of the application and any data retrieved from disk or the network. Views hold a reference to a model, watch it for updates, and respond to those updates by rendering the model in its current state. 'rendering' could refer to manipulating the display list in flash, outputting some text to stout (or trace) serving up some JSON from a server app, whatever way of expressing the state of the model your app requires. Views are also responsible for handling events that occur in their domain, and forwarding them to the appropriate Controllers. Controllers exist to manipulate models. The only acceptable way to alter a model is via a controller. Whether its storing data from a Web service in the model, or altering the state of the app in response to user interaction, the controllers hold all of the business logic that define how the app behaves. Ideally, in AS3, the models consist of no methods except accessors that retrieve values from private vars and store values there and notify subscribed views of the update. Event dispatcher is a fantastic base class for a model. Equally, wherever possible, a controller should only consist of methods. Properties are for the model. This sets up a unidirectional flow of interaction and display. The controller populates the model, the model notifies the views, the views change. The changed view incites some user interaction, the view tells the controller what the user wants to happen, and the controller alters the state of the model accordingly, which then notifies the views to change, and so on and so forth. Ross P. Sclafani Owner / Creative Director Neuromantic Industries http://www.neuromantic.com http://ross.sclafani.net http://www.twitter.com/rosssclafani 347.204.5714 On Feb 15, 2012, at 1:46 PM, Merrill, Jason jason.merr...@bankofamerica.com wrote: Calculations would not be in the controller, they would be in the Model. Sometimes you can justify them being in the view if it's related to the view. Calculations are also in a Service class if they are part of a service in some way. Jason Merrill Instructional Technology Architect II Bank of America Global Learning ___ -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of David Hunter Sent: Wednesday, February 15, 2012 1:32 PM To: Flash Coders List Subject: [Flashcoders] MVC style Hello list, If I am making an application with MVC pattern and calculations are needed to be performed on the data when the user interacts with the application, would you: do the calculations in the Model? create a separate class that handles the calculations and puts the results in the model? do the calculations in the Controller? looking forward to hearing people's thoughts on this, david -- David Hunter www.davidhunterdesign.com +44 (0) 7869 104 906 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses. References to Sender are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you
Re: [Flashcoders] am i loaded by another swf?
Ah.. ok. Thanks Henrik. Best, Karl On Feb 15, 2012, at 4:32 PM, Henrik Andersson wrote: Karl DeSaulniers skriver: Is there no reference in AS3 like AS2 where you can look with _level0 for the top level MC? The equivalent to levels would be the display list of the stage itself. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders