I'm very new to Coldfusion and action script, but due to job requirements, i got allocated the task of developing a cfm page where the user logs in using the embedded swf file and everything was working fine, till i decided to add the Application.cfm file for session variables.
Whenever i remove the application.cfm , everything works fine.But if i add it in again, nothing works again.... *sigh*
Error given out by flash is :
Error opening URL "http://192.168.1.6/flash/testing/LoginProcess.cf m"
Anyone knows how to fix this?
Application.cfm
The Action Script
The LoginProcess.cf m
Login page, with the flash embedded
Whenever i remove the application.cfm , everything works fine.But if i add it in again, nothing works again.... *sigh*
Error given out by flash is :
Error opening URL "http://192.168.1.6/flash/testing/LoginProcess.cf m"
Anyone knows how to fix this?
Application.cfm
Code:
<CFPARAM NAME="timeout" DEFAULT="#createtimespan(0,0,0,5)#">
<!--- With Session Management Enabled --->
<CFAPPLICATION NAME="Flash" SESSIONMANAGEMENT="YES" SETCLIENTCOOKIES="NO" SESSIONTIMEOUT="#timeout#" >
<!--- CF will not set the client cookies automatically, so set them manually as per-session cookies --->
<CFIF not IsDefined("Cookie.CFID")>
<CFLOCK SCOPE="SESSION" TYPE="READONLY" TIMEOUT="5">
<CFCOOKIE NAME="CFID" VALUE="#SESSION.CFID#">
<CFCOOKIE NAME="CFTOKEN" VALUE="#SESSION.CFTOKEN#">
</CFLOCK>
</CFIF>
Code:
submitURL = "http://192.168.1.6/flash/testing/LoginProcess.cfm";
//Define function to process form data
function checkUser():Void {
//Creates an instance of LoadVars to send form data to Coldfusion.
// creating an Array with LoadVars called dataOut to send the form data as a bulk to Coldfusion.
dataOut = new LoadVars();
//These variables will be the once that will correspond to the variables in Coldfusion.
dataOut.Fname = userinput.text;
dataOut.Fpwd = passinput.text;
// Create another LoadVars instance to receive the server's reply
replyData = new LoadVars();
// Initialize reply variable.
replyData.reply_username = "";
replyData.reply_pwd = "";
replyData.reply_status = "";
replyData.reply_tokencf ="";
replyData.reply_ftoken ="";
replyData.onLoad = handleReply;
// Submit the order data
dataOut.sendAndLoad(submitURL, replyData, "post");
}
function OnReset():Void {
userinput.text="";
passinput.text="";
status_txt.text="";
}
function handleReply(success) {
if (success) {
if (replyData.reply_status) {
gotoAndStop(3);
}
else {
mx.controls.Alert.show("Login Failed!", "Alert");
gotoAndPlay(1);
}
}
else {
mx.controls.Alert.show("There was a problem submitting your login. The server may be down or not responding.", "Alert");
}
}
Code:
<cfset LoginName=#Fname#>
<cfset LoginPwd=#Fpwd#>
<cfquery datasource="#FlashDB#" name="CheckLogin">
Select *
From Clients
Where AccountName='#LoginName#' AND Password='#LoginPwd#' AND LoginStatus <> 'True'
<!--- this is for web login, not flash login --->
<!--- AND FlashLogin <> 'True' ***might cause timeout error, if timeout doesnt work*** --->
<!---AND suspend <> 'True'--->
</cfquery>
<cfsetting enablecfoutputonly="YES">
<cfcontent type = "application/x-www-urlform-encoded">
<cfif CheckLogin.FlashLogin NEQ True>
<cfset LoginStatus=1>
<cfset CurrBalance = #NumberFormat(CheckLogin.CurrencyBalance*100, '99')#>
<cfset returnToFlash = "&reply_username=#URLEncodedFormat(LoginName)#&reply_pwd=#URLEncodedFormat(LoginPwd)#&reply_status=#URLEncodedFormat(LoginStatus)#&reply_balance=#URLEncodedFormat(CurrBalance)#&reply_nick=#URLEncodedFormat(CheckLogin.LastName)#&reply_clientID=#URLEncodedFormat(CheckLogin.ClientID)#&abc=1234">
<cfelse>
<cfset LoginStatus=0>
<cfset returnToFlash = "&reply_username=#URLEncodedFormat(LoginName)#&reply_pwd=#URLEncodedFormat(LoginPwd)#">
</cfif>
<!--- FlashOutput contains the string that will be sent back to Flash--->
<cfprocessingdirective suppresswhitespace="Yes">
<cfoutput>
#returnToFlash#
</cfoutput>
</cfprocessingdirective>
Code:
<body>
<cfoutput>
<object width="350" height="250">
<param name="movie" value="Login3.swf">
<embed src="Login.swf" width="350" height="250">
</embed>
</object>
</cfoutput>
</body>