1 Reply Latest reply on May 18, 2007 7:48 AM by peterent

    Flash isn't Syncronous?

      This whole "Flash doesn't do file reading" syncronously thing is really really irritating. it just makes no sense.

      How can you say that files don't read syncronously?

      Imagine this, adding numbers isn't syncronous, or appending strings isn't sycronous. Just to add two numbers, or append two strings, you need to end your current code and continue the rest of it in an event!!!

      That woudl cause a few problems:

      1) All your local variables are lost.
      2) All the local variables in the calling chain of functions, are LOST. Because they aren't in the event's calling chain are they!

      So basically, all use of local variables is screwed. You can't use them anymore! Instead, you must use objects with properties and work on the properties, which is slower, and more awkward. This way you can pass the objects around to the events handlers. But that doesn't help our calling chain problem!

      3) We'll end up with events calling events calling events.

      Imagine you got a loop reading files, in a directory. Well, you can't do it. Unless you want to have a massive chain of events calling events calling events. And how large is flash's stack frame anyhow? Can it handle reading 1000 files? If you got 3 functions in a chain per file, and 3 functions overhead on the flash event internals overhead, that would be 6000 functions on your stack, just to read 1000 files :(

      In C, you'd need ZERO extra functions on the stack to read 1000 files :(

      This sucks. It's a mess. It's awkward. It makes no sense.

      And flash contradicts itself, by not having all of it's things async! Adding numbers isn't async. Adding strings isn't async. So why isn't reading files? I don't care if I can run 1 more function inbetween the time the file is read and the data comes back to me. I'm reading it off the hard disk and flash is much slower than C++ anyhow so I probably won't have to wait at all.
        • 1. Re: Flash isn't Syncronous?
          peterent Level 2
          The Flash Player, when hosted by a browser, has limits imposed on it by the browser. In IE for example, any ActiveX control, even Microsoft's, have the same limitations: the number of open connections to a server, the amount of CPU that it can get, memory, etc.

          Because the Flash Player is a web-based tool it is also limited to what the internet protocols allow. When you request a file from the server that is not a synchronous event, no matter what technology you use. If you write it in JavaScript, ASP, ColdFusion, etc, the request for data does not block until the data is received. It must work this way because the latency on the request could be quite lengthy. Have you ever loaded a page in the browser and just waited and waited until the data appeared? The internet is inherently asynchronous.

          The Flash Player does not read and write local files for security reasons. Java applets have a similar restriction. Allowing a program which you download over the web to have read/write access to your system is dangerous. It is unfortunate that unscrupulous people have plagued us to the extent we actually deny services that would be useful.