Mixing a little Flex with my Mach-II

ColdFusion, MachII, Web Development, Flex

One of my latest projects was to create a little contact manager / sales tool to integrate with an existing system (written in Mach-II).  Requirements dictated that I needed to have access to my already logged in user (must be aware of client session). "Down the road" requirements, are that we'd like to make an AIR port of this new feature as a standalone application. As a big fan of Flex, I thought it would be a great opportunity to test the efficacy of writing this new feature as a drop in Flex mini-application. 

Since security is handled by the existing application,  we needed to make sure the functionality of this app respected the existing security guidelines.  The best way I could think of was also the easiest...just start calling events and see what happens.

Lucky for me, it all just worked.  So here are a few examples that might help get you started if you are working on the same sort of project.

 

On creationComplete I call a method named "init()" to get that user's set of contact data:

private var myLoader:URLLoader;

public function init():void
{
	var myReq:URLRequest = new URLRequest('/index.cfm/event/GetContactData);
	myLoader = new URLLoader()
	myLoader.addEventListener(Event.COMPLETE, dataComplete);
	myLoader.load(myReq);
}

Important:  Notice the event listener I added to call the dataComplete method once the request was completed. 

 

Once we have that initial set of data, all that is left is to start POSTing the create/edit/deletes the user is making to his contacts.

Here is an example of doing an HTTP POST request and passing my Contact object to a Mach-II event:

private function saveContact(Contact:ContactVO):void {
	var myHTTPService:HTTPService = new HTTPService;
	myHTTPService.method= "POST";
	myHTTPService.url = '/index.cfm/event/SaveContact';
	myHTTPService.addEventListener(ResultEvent.RESULT,function():void{init()});
	myHTTPService.send(Contact);
	Alert.show('Contact has been saved.');
}

Note:  Check out how we send the Contact object without doing anything tricky?  All of the properties of my ContactVO are available as event Args in my Mach-II listener. 

 

Here is another example of doing an HTTP POST request, but passing individual variables:

private function submitNote(htmlText:String,plainText:String,Contact:ContactVO):void
{
	var myHTTPService:HTTPService = new HTTPService;
	var obj:Object = new Object();
	myHTTPService.method= "POST";
	myHTTPService.url = '/index.cfm/event/saveNote';
	obj['notetext'] = htmlText;
	obj['notepreview'] = plainText;
	obj['contactid'] = Contact.ContactId;
	myHTTPService.addEventListener(ResultEvent.RESULT,function():void{init()});
	myHTTPService.send(obj);
}

Note:  Notice how we create an object and define the properties we want to send, and then pass that new object in the POST.

Looking to hire ColdFusion/Flex Developer (Addison, TX)

ColdFusion, Web Development, Flex

I am looking to hire a full time (on site only) ColdFusion developer.

The type of applications we work on range from support of old legacy applications to object oriented ColdFusion business layer with Flex 3 UI.

Experience working in frameworks is a major plus.

Industry: Mortgage software
Location: Addison, TX
Start Date: Immediate
Salary: Depends on Experience

About FICS:
FICS is a small, family owned company (50ish employees).
Founded in 1983 and headquartered in Dallas, Texas, Financial Industry Computer Systems, Inc.
(FICS®) specializes in providing flexible, comprehensive residential and commercial technology
solutions to the mortgage industry. FICS' solutions are designed around the latest technology,
while incorporating innovative imaging and Web-based capabilities into its full suite of products.


Job Function:

  • Troubleshooting/enhancing/support of existing web applications.
  • Developing primarily in ColdFusion with more and more Flex/ActionSript as we are moving towards Flex as our main UI technology.
  • HTML, JavaScript, CSS, minor image manipulation/creation (buttons, etc)

Requirements:

  • At least 2 years ColdFusion experience
  • Web design/layout experience with HTML, CSS and JavaScript
  • ActionScript/Flex experience is a plus
  • A good troubleshooting ability is necessary.

 

 

Please send resumes to aaronjlynch AT gmail DOT com

Thanks!

Aaron

Simple Session Timeout for Flex App

Web Development, Flex

If you have ever done any development in Flex you know that there isn't a good counterpart to ColdFusion's session management (ie timeout length and such).  So, what do you do if you want to time a user out from a secure are of your Flex application? 

The application in this case is comprised of many individual view components running through one single main view.  So the code in my examples is located in that main view component.

The Timer:

"The Timer class is the interface to Flash Player timers. You can create new Timer objects to run code on a specified time sequence. Use the start() method to start a timer."

Once we have the flash Timer imported we need to create three methods: 

One to initialize the timer, one to call when the timer is finished, and one that resets the timer.  As you can see in the examples, any time the mouse moves the timer is cleared which has the effect of keeping our "session" alive.

The method initTimer() is called upon creationComplete of that main view component.  creationComplete="initTimer()"

public var myTimer:Timer;
			
private function initTimer():void
{
     myTimer = new Timer(300000);
     myTimer.addEventListener("timer",logout);
     this.addEventListener(MouseEvent.MOUSE_MOVE, resetTimer);
     myTimer.start();
}

private function logout(event:Event):void
{

   //place code here to run your log out routine
   
}

private function resetTimer(event:Event):void
{
     myTimer.reset();
     initTimer();	
}

NOTE:  For those wondering, this particular application does not require a session be maintained server side as we reauthenticate each request as it is received.

tags:
Flash, Flex

Search

Fuelly