Passing Data from Coldfusion to Flex - apache-flex

I'm working on a flex app which is to be embedded in a Coldfusion page and am wondering what the best way is to pass data from the coldfusion page into the flex app. The app really just represents a module in the Coldfusion application. I normally just use remote object calls and the creationComplete method in Flex to instantiate any variables and methods I want to run at start.
Since flex doesn't represent the entire app, I was wondering if there is a better way aside from creationComplete to pass a coldfusion variable into flex when the use clicks on the link to the flex app.

Related

Create fat client (RIA) with HTML - controlled environment

I realize that this question can start a discussion but that's really not my intention. We've created a Flex Application to take tests from candidates. The advantage of the Flex Application is that all state can be stored in the application running in the browser of the client. Things like time limits, navigation, scoring, ... can all be handled within the application without us having to worry about a back button for instance. Even running the app offline with Adobe Air isn't that hard.
My question now is if such an application could easily be made with HTML, Javascript, Ajax, ... ? The reason I'm asking is because an application in HTML would be much easier to distribute on Mobile devices for instance. Also, our domain model for instance is mostly implemented in AS3 (Flex) so using it along the server side means porting it to C#.NET. (with two codebases as a result).
Look at any good MVC toolkit, you will easily be able to handle this. Castle project is good as is Microsoft MVC, both of which allow you to choose from a variety of view engines to handle the actual page rendering thereby allowing you to choose the most 'mobile efficient' engine...
As for the technicalities, you would store all persistent data in a server session object.

Can I catch keyboard events in Flex, without forcing users to click on the stage?

Greetings,
Looking at the examples I've found as a result of Google searches, I can see that the common method suggested for handling global keyboard events in Flex, is to attach a listener in the application complete event of a Flex application.
However, no matter what I try, I have not been able to catch events without clicking on a point on the page, which is hosting my Flex application.
Moreoever, if I use a Flex component in a web application, where there is also html and Javascript, I'd still like to be able to grap global keyboard events, even if the embedded flex component (in flash player) does not have focus.
So is there a reliable method for connecting flex applications and components (when they're embedded in a web page) to keyboard events?
Best Regards
Seref
You could use the javascript bridge. You would need to set up listeners in javascript that pass data to your Flex application.
As for directly capturing them, the browser will only send events to the Flash plugin if the plugin has focus, so no, you cannot capture them directly in your Flex application.

Is it possible to create a separate file for httpservices in flex and what are the best practices

Hi I am new new to flex development.
I am building a flex application which uses rest APIs.
Right now I have created different for different API calls (login, logout, search etc.) And all these services are in main mxml application file.
I am wondering if I can create a separate mxml file like services.mxml that I can use to call any service.
Is this the right approach?
And can you tell me how t do this?
Thanks
Priyank
Yes, you can encapsulate Flex code so it is not all in the same file. Yes, you can also do this with services. In fact the Cairngorm framework uses that exact approach. [And I assume other frameworks do too].
When you create a component architecture the trick is figuring out how components communicate with each other. In Flex, a component can dispatch events to communicate with it's parent. And it can have methods or properties so the parent can communicate with the child.
Encapsulating all services to a single is fine, but you'll need to figure out components will access those services and how those services will send results back to the components. It's not a simple proposition.
I think you need to research the flex component lifecycle a bit and read up on creating Flex Components or ActionScript classes.
Here are a few resources:
http://www.adobe.com/devnet/flex/components.html
http://www.adobe.com/devnet/flex/articles/creating_components.html
http://livedocs.adobe.com/flex/3/html/help.html?content=Part4_CreateComps_1.html

Can A .swf loaded with SWFLoader propagate events to the parent application?

I am building a compartmentalized Flex application which uses <SWFLoader > to load additional Flex applications inside it. I am currently planning on using the LocalConnection class to have these two applications talk to each other, but I'm wondering if there's any kind of event driven way to have actions in the internal application propagate to the parent application, and/or any way for the parent application to trigger events in the internal application?
yes it can but be careful what types you pass across the bridge if you are loading with loadForCompatability=true. Have a look at this document LoaderInfo paying particular attention to sharedEvents. It basically allows you to raise events from the subApplication to the parent and vice versa. For more complex scenarios, using AIR have a look at the child/parent Sandbox bridges.

API For Flex Apps To Interact

I have a large flex application (the app) running on one server, and many small flex applications (widgets) running on another server, which are to be included in the app so that visually the user see's one continuous application. Due to proprietary third party software, this structure cannot be changed. I am looking for some way to allow the app and the widgets to communicate, allowing the app to make changes to the widgets and the the widgets to notify the app when events are triggered, so that user interaction is fluid and continuous.
There are a few related questions which indicate it's possible to do this by setting up event triggers and listeners. I am wondering if there is any standardized way to do this (the answers aren't very clear) or if anyone has developed a library or API to make this easier.
Something I've had success with is using javascript as a bridge between the swf files. It's a nightmare to debug but it works quite well. Check out the tutorial here for a quick discussion of how to interact with javascript from within flash and vice versa
I assume you are running your Flex apps on a client, not a server; is that correct? You want to swfs from multiple servers to act as single application, correct?
I believe that you can communicate between two swfs using LocalConnection:
http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/net/LocalConnection.html
The other questions you link to seem to talk about loading onw swf inside the oher; which is a separate approach.
Use Modules and ModuleLoaders. You'll be able to set the security context, and if you sublcass the Module class and add your own API, you can have a consistent way to communicate with your modules.
Check here for a simple Module:
http://blog.flexexamples.com/2007/08/06/building-a-simple-flex-module/

Resources