Actionscript 3 :: Do Lightweight REST Calls In Flex
Dec 19, 2010
We are converting a Flex application to use some REST APIs.
When adding the mx.rpc.http.HTTPService class to the code, the SWF binary output grew from 175KB to 260KB. This is an unacceptable hit.
Is there any better way to do lightweight REST calls from a Flex app? Are we better off using an external interface JS just to make the calls from there?
I have a flex app hosted on a windows server running IIS. That same server has some rest services that the app interacts with. The rest services have windows authentication so that their urls cannot be called without credentials. The flex app needs to be accessible to the public so its files are accessed by enabling anonymous access. The problem is of course that when the app tries to call the rest services the browser pops a dialog box asking for windows username and pass. I naively hoped that if I set the anonymous access on the flex site to use the credentials of a windows account that had permission to view the rest services that would resolve the matter. I hoped that IIS would see the browser used the proper creds to view the flex app and use those same creds to get the rest services. Wrong, that didn't work.
So is what I want impossible? I'd like to find a way to not force the user to enter windows creds, keep the rest services using windows authentication, and have the flex app able to access the rest urls. Any ideas? Am I missing something? Also, it may turn out that the flex app is running on http and the rest services must be called with https. Does that change your answer?
In the root of my application I have 5 named "slots" (layers) that I want content to appear in. Should I be using Canvas, Group or something else for each of these slots? I don't need any kind of automatic layout inside these slots.
I'm looking to be able to run some actionscript 3 in the background to handle some audio and build a javascript front-end. I heard that you can simply compile actionscript 3 and run it using the flex framework
Have you ever wanted to track down where that spare trace is coming from, but can't be bothered to use tr.ace which makes you type more and has limited functionality? Introducing t.race - the super lightweight debugging tool! To use, just create t.as and copy the following code. To call t.race, just:
The system is a Flex application communicating with a WCF REST web service. I am trying to upload a file from the Flex application to the server and am running into some issues. I'm using a FileReference in the Flex app to browse and upload the file as defined here: [URL]. I am then receiving the file as a Stream (shows as System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream in the debugger) in the WCF REST web service (using project type of WCF 4 REST Service)
[WebInvoke(Method = "POST", UriTemplate = "_test/upload")] public void UploadImage(Stream data) { // TODO: just hardcode filename for now var filepath = HttpContext.Current.Server.MapPath(@"~\_testfile.txt"); using (Stream file = File.OpenWrite(filepath)){ [Code] .....
Positioning / Scrolling problem with Flex popup I am trying to get the main control bar on my application to control the location of a popup that has been opened using PopUpManager. create PopUp(this,JakePanel,false);Initially the page looks like this:After I scroll the page it looks like this: What I would like is for the Popup to scroll with everything else.[code]
I have a flex repeater for an accordion inside a TitleWindow that is quite slow, I've already set recycleChildren to true, which has helped, but it's still slow on the first load and causes the animation to stutter when I open the TitleWindow.
The repeater is just one part of what's visible in the TitleWindow, what I would like to do is have the repeater load after the rest of the content in the TitleWindow so the animation of the TitleWindow being opened doesn't stutter (the main problem).
I'm making multiple similar calls with similar results to one remote object. Because these calls are so similar and very changeable, I've been keeping the name of the remote method in a config file, and when I need to make the call I use getOperation() on the remote object, and call send() on the operation object. However, the requirements have changed so that not all of the calls will have the same number of parameters. Because send uses ..., will I be able to continue using the same formation and pass an array, or will send() treat that as passing one argument of type array?
I have a component called a TableDataViewer that contains the following pieces of data and their associated set functions:[code]This component is nested in another component as follows:[code]Looking at the trace in the logs, the call to set table is coming before the call to set dataSetLoader. Which is a real shame because set table() needs dataSetLoader to already be set in order to call its load() function.So my question is, is there a way to enforce an order on the calls to the set functions when declaring a component?
I would like to change the parameters of an object, or values like width and height, via javascript but I need a very lightweight method. In the end some of the thing that I want to change would be width, height and a parameters src value. So far I'm having no luck of getting it by id $('#test').attr('src','test.html') or the javascript method of getElementById().
What is the best - lightweight - method to do this?
I have to deploy a webapp on Tomcat 6.0.24, serving some webservices that should be accessed with REST-style methods (not fully REST, since the used flex class HTTPService can just send GET and POST).
The webservices are deployed at [URL]
The problem is that the policy of flex sandbox (i think it is called so) requires that the server with the services has to offer a file crossdomain.xml on his root directory.
I created that file with the following contents:
<?xml version="1.0"?> <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> <cross-domain-policy>
[Code].....
I am testing it and it does not seem to work. Maybe i am not doing it right. PS: I think Apache is not configured to manage Tomcat-addressed requests, every request is dispatched by port, i think. I can not provide the exact flex error since i am not developing that part. I will try to make a minimal example in the next hours and see if i can reproduce the problem.
I am trying to integrate Flex application to access Rest services (using Jersey) through BlazeDS. I'm able to get Rest + Jersey working (pretty straight forward I guess) and I was able to configure Flex + BlazeDS. I'm looking for help to invoke rest services (different methods) from Flex UI based on the annotations specified such as @Path in my rest service class.
I am using Flex and with the AS3 libraries.I can make calls etc but when i get values returned in the event,they are in RawResult. I am not sure how to turn that into an arraycollection etc so i can make use of it in flex, or if there is a better way of accessing the data, generally speaking.
var friendsDoc : XMLDocument = new XMLDocument(e.data.rawResult); var decoder:SimpleXMLDecoder = new SimpleXMLDecoder(true);[code]....
I have to use flex 4 for the front end and php with Symfony 2 as backend. I want to use amf to call remote methods on the php. I have known that Symfony 2 does not have plugin for amf communications with Flex. In this case how can I connect them? or I have to use httpservice/webservices which is slow in performance.
Web 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]
I have the following application in flex. I want to call two different remote objects in parallel.
[Code]...
Now what the methods do is to print sth. when they are called, then wait 8 secs and print sth. after that. When clicking each button seperatly, it works, both methods are started in parallel. However, calling both method the same time, leaves one service to wait with its call while until the other is executing. How can I avoid that?
I have a Flex 3 application that makes a call to a webservice. That webservice calls returns a 2 Mb file that flex reads and parses. The problem is that it takes sometimes 45 seconds. I was wondering if there is a way to cache the response form the webservice? So the next time I load the flash movie it doesn't have to re-download the full file but just the updated data.
I have this button: <s:Button includeIn="MeniuPrincipal" label="Descarcare Date" click="downloadLmData(event)"/> And this click event handler: protected function downloadLmData(event:MouseEvent):void { downloadData('competenta', 'competente'); downloadData('localitate', 'localitati'); }
The downloadData function looks like this: private function downloadData(item:String, items:String):void { try { var colVar:String = 'col' + cappitalize(items); this.status = "Descarcare date in curs..."; this[colVar] = null; [Code].....
The problem is, all calls are ignored, except for the first one. Is there any "queuing" mechanism which would allow all calls to be made?
I have a Flex 3 application that makes a call to a webservice. That webservice calls returns a 2 Mb file that flex reads and parses. The problem is that it takes sometimes 45 seconds. I was wondering if there is a way to cache the response form the webservice? So the next time I load the flash movie it doesn't have to re-download the full file but just the updated data.
I'm on Flash Builder 4.5 and I'm using remote object with amfphp and when I call two method (method1 and method2) at the same time the response of method2 always arrives after method1's response even though method2 is much more faster to return the result.re's the scenario:I set a remote object which refers to a remote php class "Newletter" which contains the sendNewsletter and getProgress methods.Here's the code:-sendNewsletter() reads the email archive and send the newsletter. After each email has sent it writes a log into the database.-getProgress() reads the log wrote by sendNewsletter, counts how many email have been sent, compares it with the total number of the email that have to be sent and return the progress percentageFrom the flex interface the users select a Newsletter to be sent and click on a "send" button which calls a function that calls the sendNewsletter() and then instantiate a loop of calls to getProgress (as you can see when getProgress returns something it calls the setProgress which updates a progress bar and calls getProgress again until the progress percentage reach 100%.
So right after I call sendNewsletter() I call getProgress() on the same remoteClass().sendNewsletter() can take several minutes to complete (in my tests for sending 4 email it takes about 4 seconds so I think that sending thousands of email will take much more!!) and the trouble I'm encountering here is that getProgress() result arrives only after sendNewsletter() concludes its execution while what I would like to achieve is:
I have 5 Cairngorm Events that I am dispatching at the same time(one right after the other) - all of which call a separate HTTP Service. This works fine when I run the application locally however when I deploy my project to a Glassfish server, it only works intermittently, with the app hanging when it doesn't work.
My temporary work around to this is to chain some of the events together so less call are going out at once, but I don't really like this as a viable solution because it slows down performance.
Is there a maximum number of HTTPService requests that Flex can make at once before it hangs?
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 web service written in ColdFusion. In this web service, there are two functions; one is to return all the questions in a quiz and the other one is to return all the answer selections to the questions in a quiz.
[Bindable] private var questionArray:ArrayCollection; private var cfquiz:RemoteObject;
[code]....
I have the codes above. loadQuestions is called at creationComplete to retrieve the questions. Things are working fine. What I want to do is to call another function within the same web service, returnAnswers, to return the answer options for a question. Since I have cfquiz associated to the web service already, I was using cfquiz to call returnAnswers. However, there is an event listener associated to cfquiz already, resultHandler is being called when returnAnswers comes back with the results.is it possible to check which function returns the results within resultHandler? If so, how? And second, what is the best way to handle calls to multiple functions within the same web service?
I am working on an app, where the server time needs to be displayed on a Flex app. The idea is to make a BlazeDS remoting call getServerTime() once during the app intialization and then use a local Timer class to keep updating the display.( I don't want to bombard server with getServerTime() for each second). My question is, once I have a AS3 Date object. How do I increment it by seconds?