Flex3 :: Synchronous And Asynchronous Call
Jan 12, 2010what is synchronous and asynchronous call in flex. Why Httpservice is asynchronous and how to make a call to asynchronous call.
View 3 Replieswhat is synchronous and asynchronous call in flex. Why Httpservice is asynchronous and how to make a call to asynchronous call.
View 3 RepliesIs there a way to have a synchronous call to a URL to retrieve the HTML code? If not, is it possible to turn an asynchronous call into a synchronous one using some trick? I can't believe Adobe wouldn't implement this option. I tried looping until the result is back but then the status function never fires making my loop infinite.
ranting.turn("ON");
I'm a ColdFusion developer and recently started working on a project in Flex. I am getting more and more frustrated with AS and Flex lately. It seems that whatever I'm trying to do is either really hard or impossible while it usually can be done with one line of code in ColdFusion. I'm still learning these languages and I'm sure my lack of knowledge is the reason but for some reason I can't get ahead with my project. It looks like the learning curve is much steeper than it should be.
ranting.turn("OFF");
Anyways, here's my code for testing this functionality. The main application file looks like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
<mx:Script>
[code]....
This works OK except the function returns false before the HTTP call returns its result. If I un-comment the while loop the onStatus function will never be called and therefore end up with an infinite loop. Not sure why this happens.
In the code below when I call chkAuthentication function from another function the remoteObj.login (login function in my service file (.php)) is called after the remaining code in that function. i.e., the loginStatus is returned from the function before the result-handler function loginResult is called. but my loginStatus is supposed to be set in loginResult function. It seems that the asynchronous behaviour is the culprit. what should I do in order to get the loginResult function to complete first?
[Code]...
Is it possible to make a synchronous xhr call from flash?How do you do this in actionscript?
View 1 RepliesI have a big loop in actionscript that sends lots of data to an url:
for(var i=0;i<1000;i++) {
var request:URLRequest = new URLRequest();
request.url = url;
request.method = URLRequestMethod.POST;
request.data = data;
var loader:URLLoader = new URLLoader();
loader.load(request);
}
The problem is because URLLoader can make only asynchronous calls, it sends all those thousands requests at once which kills webserver. Also it acts a bit strange on top of that. Lets say the loop is running for 5 minutes. For whole 5 minutes there is no requests coming to web server, then at the end they all are sent at once. I already tried everything I could possibly think of (empty loops, callbacks, delays) - nothing works. All requests are sent at once no matter what. How to make requests synchronous, so it will send one request after another?
Is there a way to make synchronous calls using RemoteObject in Flex?
Solution: Add the second call to the result handler of the first call, having a token check for multiple originating calls.
I need a Synchronous loader for my AIR application.The URLLoader class does not meet my needs because of its asynchronous nature.It continues the execution of code. I need to stop the code until the loader loads the Html text.
View 5 RepliesWeb service calls are asynchronous in flex, but I wanted to wrap a web service call in a class to provide synchronous encapsulation. Something like the below - the user could call getMyMethodResult and get the result returned by the web service. I expected the thread that recieved the soap response would populate the variable _result and mean that getMyMethod would, after a time, find _result is not longer null. But it doesn't! Can anyone explain why this does not work?[code]
View 1 RepliesI'm using flex4 and actionscript, and need to treat an event in a synchronous mode. Is it possible that? More exactly, i want to execute some queries in a database, and need to be synchronously.
View 1 RepliesIs it possible to make httpService Requests synchronous in Flex?
View 2 RepliesI have small Flex web based util with single button. On this button click a request is sent to server and the response must be read in the same call.This is important not to wait for response with event handler (which is trivial).Basically this is synchronous call.I am ok with blocking ui and so on.
View 1 RepliesA simple piece of code that should trace [code] and I get something completely far away from that,[code]Is the trace function that bad? that slow? is it the fact that passing an argument to the function take so much time compare to the other one?is there something I can do to avoid this type of weirdness ?(For the record, my project is not to trace {rien, done and test}... I have 15k lines of codes that react completely differently if I compile them with "Omit trace statements" or not.
View 2 Repliesi am using soundmanager to order sounds. my site preview, in home page, square shapes comes into stage and you can drag drop them, all shapes binded its own sound. if they are colliding binded song will play.
the problem is i have 3 second timer to control sounds. every timeout i have to stop sound and play again for synchronous issue, that is my solution for that part. but sometimes before loop, there is an annoying little silence.
I need to write an application to asynchronously upload a file to a server.
Anyone have any examples or tips as to how I can do this?
As my first Flash project of any consequence, I've created a simple banner animation that (basically) loops over a few different images, panning and fading in/out by setting the x,y coordinates, setChildIndex, and alpha. This was easy enough to code with an ENTER_FRAME event handler and a few state variables.Here are the most relevant snippets:
// Main
// XXX - Putting addEventListener() first would
// make some sense, but I would still have
[code].....
sample for asynchronous file upload using flex filereference object
View 1 RepliesHow can we get data from the server in an asynchronous way in Flash? I am looking for something like XHR in actionscript.
View 2 RepliesI want to build a simple web 2.0 collaborative website using asp.net MVC2 or Flash and I want to receive events from a web based interface to a desktop AIR application. For e.g, someone makes a comment on a blog post, I want that information to be passed on to a desktop air application showing that a new comment has been made. What would be a good technique to receive asynchronous events?
View 2 RepliesI have a piece of code in my game which looks a lot like this: MultiplayerAPI.createGameRoom(function(){ successFunction(new Object()); }); Basically, the createGameRoom is performed and, upon success, the function I passed is run. However I've been running into some strange bugs recently and I'm wondering, is the instance of "new Object();" the same each time the callback function is run? It needs to be a different, fresh instance of Object each time, but I'm having some garbage collection issues which make me think it's passing the same object each time that event callback is fired,
View 2 RepliesI have a simple accessor in my class:
public function get loggedIn():Boolean
{
var loggedIn:Boolean = somePrivateMethodToCheckStatus();
return loggedIn;
}
The API I'm now working with checks login status in an asynchronous fashion:
API_Class.addEventListener(API_Class.LOGIN_STATUS,onStatusCheck);
API_Class.checkLoginStatus();
[Code]....
Is there a way I can perform this asynchronous request without exiting my accessor?
If I have one parent class that instantiates 5-10 different child classes, each of which need to load multiple assets etc, how can I check within that parent class to make sure all of the 5-10 children are loaded & ready to go before telling the program to continue?
The tricky part is that the exact number of those 5-10 classes that are instantiated is determined at runtime, so I can never be certain which I should be waiting on and which not to be waiting on. And just to be clear, these are different modules of sorts, not multiple instances of the same exact class.
I'm currently able to record audio and video (from a webcam) to a Flash Media Server. However, in some cases users have a webcam with no builtin
microphone. In that case the flash client uses the default microphone with 'Microphone.getMicrophone();' and possibly selects the micrphone of the PC.
A delay between audio and video is caused in cases with a separated webcam and microphone. There isn't a lot of delay on an internal network (e.g. LAN) however, there is a very large delay between audio and video on an external network (e.g. WAN).
I have created a client with Flex Builder which works in a browser but also in an Air windowed application. I must connect it to a server and it has to do asynchronous request related to changing data of the server.Because of the too much expensive cost of LiveCycleDS license, I was looking for other ways, maybe open source and i found the following solutions:
Adobe BlazeDS
Granite Data Services
WebORB Community Edition
I want to ask you which is the easy way to create the solution described above, expecially i want to use J2EE application server type.
I'm developing a Flex application and am having some trouble working with asynchronous calls. This is what I would like to be able do:
[Bindable] var fooTypes : ArrayCollection();
for each (var fooType : FooType in getFooTypes()) {
fooType.fooCount = getFooCountForType(fooType);[code]....
The issue I'm running into is that both getFooTypes and getFooCountForType are asynchronous calls to a web service. I understand how to populate fooTypes by setting a Responder and using ResultEvent, but how can I call another service using the result?
I have a recursive call which includes an asyn operation (file copy) .. I want to find out when the recursive call finishes (along with all asyn operations).
private function copyInto(directoryToCopy:File, locationCopyingTo:File):void
{
var directory:Array = directoryToCopy.getDirectoryListing();
[Code]....
This may be a very basic question but I cannot work it out now. I have a 'flash banner' on my site for which once clicked on you go to another page on the site. I want to track this click as an event. HTML event tracking works fine. Previously the code I used was:
[Code]....
I have a flash site that calls a JavaScript function to track events inside of the application, the _gaq is already implemented in the section of the html and it works perfectly fine with one account:
function customTracker(clickEventName)
{
_gaq.push (["_trackPageview", clickEventName]);
}
but now my customer wants to include special events from 3rd party companies and needs these to track into a different GA account. Before I try this out on the live server I wanted to ask if this would work:
function customTracker(clickEventName)
{
_gaq.push(["_setAccount", "UA-XXXXXXXXX-X"]); // the regular account
_gaq.push (["_trackPageview", clickEventName]);
[code]...
I am writing test cases to test function with flexunit 4. I am using aysnc method.
But when I add two or more asyncHandlers to the instance. I meet the problem: Error: Asynchronous Event Received out of Order.
Code snippets:
[Test(order=1, async, description="synchronize content on line")]
public function testSynchronizeContentOnline():void
{
var passThroughData:Object = new Object();
[Code].....
In Flex, I'm making a set of asynchronous calls:
service.method1.send().addResponder(responder1);
service.method2.send().addResponder(responder2);
service.method3.send().addResponder(responder3);
I want to execute some code after all of these service calls have returned (either success or failure, I don't care which). How can I do this?
I want to download a file in flex. Here is my desired flow User clicks "view" Code goes to backend and get the file as an array of bytes bytes sent from java to flex via a callback flex then opens dialog and user decides where to save the file Unfortunately the last part is not on a user event but on the callback from the server. When I call new FileReference().save(...) it tells me this. An alternative could be
User clicks "view" Flex shows user the dialog and user chooses where to save file Flex goes to backend requesting bytes of file bytes sent to flex and data is saved. For this approach I am unsure how I can make the save asynchronous from the dialog. I want the user to save a file but the data but come from an array of bytes from the backend