Avg. Rating 4.0

Problem

Always wanted to have an application where by if someone wanted to view an admin page he/she has to login first.

Solution

In order to login one has to click a login button which popups a login screen. This post will show how to dispatch a login success event from a popup to the main application so that in the event of a success the viewstack child is changed.

Detailed explanation

Hi guys, i was working on a flex application which required some sort of authentication to be done in order for someone to update some staff. The only way i could do it was through a popup login window. i spent alot of time searching the web for a solution but only found everything was similar to this post on Bruce Phillips blog "http://www.brucephillips.name/blog/index.cfm/2007/3/16/Developing-A-Login-System-For-A-Flex-Application-With-A-ColdFusion-and-Database-Backend-Part-1". Its a great example and i had used it in one of my projects but the problem is that i was using a popup window this time and didnt know hw to dispatch popup events to main application. Anyhow i got help from many guys from yahoo Flexcoders forum and came up with a solution finally.

in this senario i have a main app called "login_example" which has a viewstack that has two custom components the first one is the home view "home.mxml" and the second is the admin view "admin.mxml". inorder to access the admin view one has to login. when one clicks the signin button on the main application a popup login form appears and then you can input the username and password which a then verified to see if they match with whats in the database by the login.cfc. if there is a success the view changes from home to admin.

hope that this helps someone. please download the files and look at the code. it is well commented.

Report abuse

Related recipes