Coordinates of an input type image
5 comments Posted by: NahuelIn my previous post, Paul Hastings asked how to capture the x,y from a clicked image. In response to that, I made a small workaround that requires an invisible text field.
This is not the cleanest way to do it and I'm sure someone will come up with a simpler solution.
So here it is:
<cfsavecontent variable="actionSend">
myImageCoords.text = "x:"+myImage._xmouse+" | y:"+myImage._ymouse;
submitForm();
</cfsavecontent>
<cfform name="myform" height="300" width="300" format="Flash">
<cfinput type="text" visible="false" height="1" name="myImageCoords" width="160">
<cfinput type="image" height="211" onClick="#actionSend#" src="images/school.jpg" name="myImage" width="160">
</cfform>View example
Download the source
5 Comments so far
Write yoursMy CFC returns a numeric 1 if the date test was good.
i want it to validate the other fields first then do a date compare of 2 date type input fields to make sure the start is not after the end date.
I originaly tried this with just AS but it dosnt work if the dates are in different years.
thanks in advance
var formvalid = mx.validators.Validator.isStructureValid(this, 'vacreq');
var startdate = startdate;
var enddate = enddate;
var vacreq = vacreq;
var d1:Date = startdate.text;
var d2:Date = enddate.text;
<cfoutput>#conn#</cfoutput>
var tdService:mx.remoting.NetServiceProxy;
var tdHandler = {};
tdHandler.onResult = function(results:Object):Void {
if (results == 1){
submitForm();
} else {
alert("Invalid Starting and Ending dates.");
}
};
tdHandler.onStatus = function(stat:Object):Void{alert("Error while calling cfc:" + stat.description);}
tdService = connection.getService("CFC.pto", tdHandler);
if(formvalid){
tdService.testDates(d1,d2)
} else {
userOnError();
}
everything works except the submitForm();
my cfc works because i get the alert if the dates are bad.
I am sure this is something odvious that i am just not seeing.
Thanks for all the hard work here. wonderful reference site.
Tim
Inside the function, submitForm is out of scope. Use _root.submitForm() and it should work.
I have the seem problem with the dates! You could send or post me the complete example of this!
I've seem ideas, I call to cfcomponent but my problem is how recieved in actionscript and how connect with the cfcomponent!
Thanks!!
Sorry i posted this here.
Laura, as usual you hit the nail on the head.
thanks
tim
The basis of this form is to allow users to request vacation. If the start and end dates are ok then the code i posted would allow the form to continue. otherwise it would alert the user about the bad dates.
Here is the CFC code i used to check the dates. I did this because my skill in AS is not that great and this seem much easier.
<cfargument name="st" required="yes" type="date"><cfargument name="et" required="yes" type="date">
<cfargument name="stt" type="string" required="no" default="8:00">
<cfargument name="ett" type="string" required="no" default="16:00">
<cfset s = st & " " & stt>
<cfset e = et & " " & ett>
<cfset std = ParseDateTime(s)>
<cfset etd = ParseDateTime(e)>
<cfif dateCompare(std,etd,'h') GT 0>
<cfset rnum = 2>
<cfelseif dateCompare(std,etd,'h') Eq 0>
<cfset rnum = 4>
<cfelseif dateCompare(std,etd,'d') GT 0>
<cfset rnum = 0>
<cfelseif dateCompare(std,etd,'d') LTE 0>
<cfset rnum = 1>
<cfelse>
<cfset rnum = -1>
</cfif>
<cfreturn rnum>
I omitted my other code here, because its not releavent but it checks the users vacation data and makes sure that the number of days they are requesting is available to them to take. if not, then it sets rnum = 3.
in my form, in the function that is attached to the send button, in the Results of my testDate call:
if (results == 1){_root.submitForm();
} else {
if(results == 0){
alert("Invalid Starting and Ending dates. Start date is later than the end date.");
} else if(results == 2){
alert("Invalid Starting and Ending times. Start time must be less than End time.");
} else if(results == 3){
alert("You have request more days off than allowed. Please adjust your selected dates.");
} else {
alert("Invalid Starting and Ending dates. Check to make sure the start and end times are not the same. And make sure the end date is after the start date.");
}
}
};