Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex actionscript extending DateChooser, events in calendar
    primarykey
    data
    text
    <p>ExtendedDateChooser class is great solution for simple event calendar used in my flex project. You can find it if google for "Adding-Calendar-Event-Entries-to-the-Flex-DateChooser-Component" with a link of updated solution in comments of the post. I posted files below.</p> <p>Problem in that calendar is text events are missing when month is changed.</p> <p>Is there <code>updateCompleted</code> event in Actionscript just like in dateChooser flex component? Like in:</p> <p><code>&lt;mx:DateChooser id="dc" updateCompleted="goThroughDateChooserCalendarLayoutAndSetEventsInCalendarAgain()"&lt;/mx&gt;</code></p> <blockquote> <p>When <code>scroll</code> event is added, which is available in Actionscript, it gets dispatched but after <code>updateDisplayList()</code> is fired, so didn't manage to answer, <b>why are calendar events erased? </b></p> </blockquote> <p>Any suggestions, what to add in code, maybe override some function?</p> <p>ExtendedDateChooserClass.mxml </p> <pre><code> &lt;?xml version='1.0' encoding="utf-8"?&gt; &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:mycomp="cyberslingers.controls.*" layout="absolute" creationComplete="init()"&gt; &lt;mx:Script&gt; &lt;![CDATA[ import cyberslingers.controls.ExtendedDateChooser; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import mx.controls.Alert; public var mycal:ExtendedDateChooser = new ExtendedDateChooser(); // collection to hold date, data and label [Bindable] public var dateCollection:XMLList = new XMLList(); private function init():void { eventList.send(); } private function readCollection(event:ResultEvent):void { dateCollection = event.result.calendarevent; //Position and size the calendar mycal.width = 400; mycal.height = 400; //Add the data from the XML file to the calendar mycal.dateCollection = dateCollection; //Add the calendar to the canvas this.addChild(mycal); } private function readFaultHandler(event:FaultEvent):void { Alert.show(event.fault.message, "Could not load data"); } ]]&gt; &lt;/mx:Script&gt; &lt;mx:HTTPService id="eventList" url="data.xml" resultFormat="e4x" result="readCollection(event);" fault="readFaultHandler(event);"/&gt; &lt;/mx:Application&gt; </code></pre> <p>ExtendedDateChooser.as</p> <pre><code>package cyberslingers.controls { import flash.events.Event; import flash.events.TextEvent; import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.controls.CalendarLayout; import mx.controls.DateChooser; import mx.core.UITextField; import mx.events.FlexEvent; public class ExtendedDateChooser extends DateChooser { public function ExtendedDateChooser() { super(); this.addEventListener(TextEvent.LINK, linkHandler); this.addEventListener(FlexEvent.CREATION_COMPLETE, addEvents); } //datasource public var dateCollection:XMLList = new XMLList(); //-------------------------------------- // Add events //-------------------------------------- /** * Loop through calendar control and add event links * @param e */ private function addEvents(e:Event):void { // loop through all the calendar children for(var i:uint = 0; i &lt; this.numChildren; i++) { var calendarObj:Object = this.getChildAt(i); // find the CalendarLayout object if(calendarObj.hasOwnProperty("className")) { if(calendarObj.className == "CalendarLayout") { var cal:CalendarLayout = CalendarLayout(calendarObj); // loop through all the CalendarLayout children for(var j:uint = 0; j &lt; cal.numChildren; j++) { var dateLabel:Object = cal.getChildAt(j); // find all UITextFields if(dateLabel.hasOwnProperty("text")) { var day:UITextField = UITextField(dateLabel); var dayHTML:String = day.text; day.selectable = true; day.wordWrap = true; day.multiline = true; day.styleName = "EventLabel"; //TODO: passing date as string is not ideal, tough to validate //Make sure to add one to month since it is zero based var eventArray:Array = dateHelper((this.displayedMonth+1) + "/" + dateLabel.text + "/" + this.displayedYear); if(eventArray.length &gt; 0) { for(var k:uint = 0; k &lt; eventArray.length; k++) { dayHTML += "&lt;br&gt;&lt;A HREF='event:" + eventArray[k].data + "' TARGET=''&gt;" + eventArray[k].label + "&lt;/A&gt;"; } day.htmlText = dayHTML; } } } } } } } //-------------------------------------- // Events //-------------------------------------- /** * Handle clicking text link * @param e */ private function linkHandler(event:TextEvent):void { // What do we want to do when user clicks an entry? Alert.show("selected: " + event.text); } //-------------------------------------- // Helpers //-------------------------------------- /** * Build array of events for current date * @param string - current date * */ private function dateHelper(renderedDate:String):Array { var result:Array = new Array(); for(var i:uint = 0; i &lt; dateCollection.length(); i++) { if(dateCollection[i].date == renderedDate) { result.push(dateCollection[i]); } } return result; } } } </code></pre> <p>data.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;rss&gt; &lt;calendarevent&gt; &lt;date&gt;8/22/2009&lt;/date&gt; &lt;data&gt;This is a test 1&lt;/data&gt; &lt;label&gt;Stephens Test 1&lt;/label&gt; &lt;/calendarevent&gt; &lt;calendarevent&gt; &lt;date&gt;8/23/2009&lt;/date&gt; &lt;data&gt;This is a test 2&lt;/data&gt; &lt;label&gt;Stephens Test 2&lt;/label&gt; &lt;/calendarevent&gt; &lt;/rss&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload