PDA

View Full Version : Is it Possible to Use MouseOver in DateChooser?


ajwei810192
04-01-2009, 08:04 PM
Hi, Guys:

I am trying to create dynamic toolTips of event labels on a dateChooser. However, as I am working on this problem, I have run into a problem. I cannot seem to get the mouseOver or mouseOut function to work and have it provide me with the date I have just rolled over or out.



<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

<mx:Script>
<![CDATA[

import mx.events.CalendarLayoutChangeEvent;

private function useDate(eventObj:CalendarLayoutChangeEvent):void {
// Make sure selectedDate is not null.
if (eventObj.currentTarget.selectedDate == null) {
return
}

//Access the Date object from the event object.
var day:String= eventObj.currentTarget.selectedDate.getDay();
var date:String=eventObj.currentTarget.selectedDate.ge tDate();
var month:String= eventObj.currentTarget.selectedDate.getMonth() + 1;
var year:String= eventObj.currentTarget.selectedDate.getFullYear();

var wholeDate:String= (eventObj.currentTarget.selectedDate.getMonth() + 1) +
"/" + (eventObj.currentTarget.selectedDate.getDate() +
"/" + eventObj.currentTarget.selectedDate.getFullYear()) ;
}
private function useDate2(event:Event):void{
trace("On Over: " + event.currentTarget.selectedDate.getDay()); //Type Error #1009
}
private function useDate3(event:Event):void{
trace("On Out: " + event.currentTarget.selectedDate.getDay()); //Type Error #1009
}
]]>
</mx:Script>

<mx:DateChooser id="date1" mouseOver="useDate2(event);" mouseOut="useDate3(event);"
change="useDate(event)"/>
</mx:Application>


Instead, I get this error from the code I have provided: TypeError: Error #1009: Cannot access a property or method of a null object reference.

If I use event.currentTarget only, I only get the id value of my DateChooser, which is date1. Could anyone please give me some tips on what I have done wrong here?

Thanks for your help.

quincewyss
04-01-2009, 09:10 PM
to answer your question yes you can use mouse over.

I think your problem come into play with the type of event you looking for in your functions:
private function useDate2(event:Event):void{
trace("On Over: " + event.currentTarget.selectedDate.getDay()); //Type Error #1009
}
private function useDate3(event:Event):void{
trace("On Out: " + event.currentTarget.selectedDate.getDay()); //Type Error #1009
}

try this instead
private function useDate2(event:MouseEvent):void{
trace("On Over: " + event.currentTarget.selectedDate.getDay()); //Type Error #1009
}
private function useDate3(event:MouseEvent):void{
trace("On Out: " + event.currentTarget.selectedDate.getDay()); //Type Error #1009
}

also just trace the event.toString() to see what the event is returning. if you are still having problems.

ajwei810192
04-03-2009, 03:48 PM
Hi, Guys:

I fiddled around with it more and made some slight progress, but I still could not get the calendar to spit out the date. Here is the latest code:


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" themeColor="#0EFF02">
<mx:Script>
<![CDATA[
private function useDate2(event:MouseEvent):void{
trace(event.target.name.toString());
trace("On Over: " + event.target.selectedDate.getDay()); //Type Error #1069
}
private function useDate3(event:MouseEvent):void{
trace(event.target.name.toString());
// trace("On Out: " + event.target.selectedDate.getDay()); //Type Error #1069
}
]]>
</mx:Script>
<mx:Canvas id="test" x="118" y="136" width="443" height="133" >
<mx:DateChooser id="date1"
mouseOver="useDate2(event)"
backgroundColor="#FFFFFF" mouseOut="useDate3(event);"/>
</mx:Canvas>
</mx:Application>


And, here is the sample output of the trace() that is working:

UITextField56
UITextField56

If I un-comment out the line

trace("On Over: " + event.target.selectedDate.getDay());

I get the following error:

ReferenceError: Error #1069: Property selectedDate not found on mx.core.UITextField and there is no default value.

Does anyone know what this means and how I might be able to fix it?

Thanks for your help.

CyanBlue
04-09-2009, 04:10 AM
Please do not delete the thread... This is the place where everybody learn, and the information in this thread can be helpful to others as much as it did to you... Thanks...