[flexcoders] PureMVC - A Cairngorm alternative
Hi Folks, Well, the first PureMVC demo is up. Have a peek at CodePeek, an Apollo application that uses the PureMVC framework to talk to Google Code. I don't know about you but it miffs me a bit that Google Code has built in language searches for languages like Eiffle, Modula-2 and REBOL, but nothing relevant to today's Flex/Flash/Apollo developer. If you want to search for code in Actionscript/MXML, Coldfusion, or CSS, for example, you have to enter a cumbersome regular expression along with your keyword search. Googs, if your listening, that pegs the red on the Bogosity Meter, IMHO. So CodePeek adds those languages relevant to our coding world in a handy dropdown. Also, when you do a search, it saves it in a local XMLDatabase on the user's filesystem, so you can get back to them easily even after you close the app. Unfortunately, the Apollo alpha currently doesn't allow us to cut and paste from its internal browser but we're told it will when the 1.0 ships. Keep in mind this is a demo. So do this: 1) Go to http://PureMVC.org 2) Click on the Demo link 3) Click on the Download link 4) Peruse and/or download the source code if you like 5) Install Apollo runtime if you haven't already 6) Click on the Install CodePeek link 7) Try CodePeek out for yourself 8) Stay tuned for more documentation explaining how CodePeek works and best practices for implementing your first application in PureMVC. -=Cliff
[flexcoders] Re: State Machine Implementation, anyone?
Very cool this SCXML stuff. checked out the w3c docs. BTW, states are incorporated into Flex 2. They're not in the alpha, but I saw it demonstrated at MAX. There is a mx:State tag that wraps an arbitrary chunk of mxml. You can have state transition effects, etc. I doubt this is embracing SCXML or anything that ambitious, but before building the FSM, I'd want to see what Flex 2 holds and build upon it. I'm pretty interested in creating an FSM architecture for Flex, myself. Drop by my site and leave me a line if you're interested in chatting offline: futurescale.com -=Cliff --- In flexcoders@yahoogroups.com, Aldo Bucchi [EMAIL PROTECTED] wrote: Hi flexies, Does anyone know of a good State Machine implementation in actionscript? One with history, concurrent states, joins, splits ( forks ), etc? I have used Kaye's ( www.flashsim.com ), ported part of Miro Samek's method based machine, modified a compiler (CHSM), and finally went half the way to creating my own SCXML interpreter. So... why ask now??? well, because after all this work it has become evident that there is so much space for different designs that hearing other people's practical experiences is, well, a very practical way to take some decisions... like the following for instance: - The state machine declaration ( states and transitions ) can be supplied in several different ways -- external XML declarations ( could be SCXML for example. Note that this approach introduces some complexity due to the async loading state ) -- inline XML declarations. -- MXML declaration ( unfortunately we cannot provide an id for a nested faceless component in flex 1.5) -- Actionscript declaration ( instantiating classes ) -- with a class hierarchy ( a la samek ) - How do we scope state and transition ids? Per state machine? per superstate? do we use paths? - There is also the debate on giving each state it's own controller ( using class inheritance to override the superstate's controller ) or using one central controller querying the machine. - How to declare event handlers ( in the same state/transition declaration or later on by hooking them with listeners ) - how do we implement guard conditions... are they necessary / benefitial at all? why not just provide hooks for complex logic then. - and Finally, how do we feed events to the machine... should we be able to call transitions directly? - MXML wrappers can be created to allow the use of binding and inline event declarations fsm:StateProxy id=openState stateMachine={sm1} stateName=open enter=trace('entering!'+event.target.name) exit=/ mx:Button label=close enabled={openState.active}/ Should we allow this without limits? Pfff. write one line of code on this domain and you will see what I mean. State machines are so broad and powerful that it is hard to see the best way to fit them into flex at a glimpse. Help / observations / links / ideas appreciated. Man, we could even create a complete osflash project devoted to state machines. ( perhaps I will if there is enough interest. let me know ) Best, Aldo -- : Aldo Bucchi : mobile (56) 8 429 8300 -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
[flexcoders] Re: State Machine Implementation, anyone?
Spoke too soon about the alpha. I remembered them saying it wouldn't be in, so I hadn't even looked. It is there after all. (I'm only just recently having time to dig into it). And certainly it does seem to be very basic. Yet another thing pushed on the 'to explore soon' stack... :) -=Cliff --- In flexcoders@yahoogroups.com, Aldo Bucchi [EMAIL PROTECTED] wrote: Hi Cliff, Yes, Flex2 has a hierarchical state implementation, but it is very basic. The good part is that it is tightly integrated to the framework and the IDE. If we were to build ( or adapt ) a full blown CHSM then integrating it with the flex state machine should be an objective. Actually, Flex2's should be easily blended into ours. Conceptually, the tasks it performs ( property overrides, child creation, etc ) could be hooked to onEnter and onExit handlers of a more robust state machine. Another idea I have been experimenting with: - We could create an eclipse plugin to work as a monitor and draw the state chart at runtime. Or we could use the classic LSO connection for this purpose. Why not wait till this conversation draws more attention and ideas before starting something. There might be more than one person reading around with a deep understanding on the subject. Best, Aldo On 1/4/06, Clifford Hall [EMAIL PROTECTED] wrote: Very cool this SCXML stuff. checked out the w3c docs. BTW, states are incorporated into Flex 2. They're not in the alpha, but I saw it demonstrated at MAX. There is a mx:State tag that wraps an arbitrary chunk of mxml. You can have state transition effects, etc. I doubt this is embracing SCXML or anything that ambitious, but before building the FSM, I'd want to see what Flex 2 holds and build upon it. I'm pretty interested in creating an FSM architecture for Flex, myself. Drop by my site and leave me a line if you're interested in chatting offline: futurescale.com -=Cliff --- In flexcoders@yahoogroups.com, Aldo Bucchi [EMAIL PROTECTED] wrote: Hi flexies, Does anyone know of a good State Machine implementation in actionscript? One with history, concurrent states, joins, splits ( forks ), etc? I have used Kaye's ( www.flashsim.com ), ported part of Miro Samek's method based machine, modified a compiler (CHSM), and finally went half the way to creating my own SCXML interpreter. So... why ask now??? well, because after all this work it has become evident that there is so much space for different designs that hearing other people's practical experiences is, well, a very practical way to take some decisions... like the following for instance: - The state machine declaration ( states and transitions ) can be supplied in several different ways -- external XML declarations ( could be SCXML for example. Note that this approach introduces some complexity due to the async loading state ) -- inline XML declarations. -- MXML declaration ( unfortunately we cannot provide an id for a nested faceless component in flex 1.5) -- Actionscript declaration ( instantiating classes ) -- with a class hierarchy ( a la samek ) - How do we scope state and transition ids? Per state machine? per superstate? do we use paths? - There is also the debate on giving each state it's own controller ( using class inheritance to override the superstate's controller ) or using one central controller querying the machine. - How to declare event handlers ( in the same state/transition declaration or later on by hooking them with listeners ) - how do we implement guard conditions... are they necessary / benefitial at all? why not just provide hooks for complex logic then. - and Finally, how do we feed events to the machine... should we be able to call transitions directly? - MXML wrappers can be created to allow the use of binding and inline event declarations fsm:StateProxy id=openState stateMachine={sm1} stateName=open enter=trace('entering!'+event.target.name) exit=/ mx:Button label=close enabled={openState.active}/ Should we allow this without limits? Pfff. write one line of code on this domain and you will see what I mean. State machines are so broad and powerful that it is hard to see the best way to fit them into flex at a glimpse. Help / observations / links / ideas appreciated. Man, we could even create a complete osflash project devoted to state machines. ( perhaps I will if there is enough interest. let me know ) Best, Aldo -- : Aldo Bucchi : mobile (56) 8 429 8300 -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links -- : Aldo Bucchi : mobile (56) 8 429 8300 -- Flexcoders Mailing List
[flexcoders] Re: Custom initial sort on datagrid
I think dg1.sortItems(sortByAge, asc) should have worked (or desc), should work... but doesn't. And changing to asc and desc instead of Array.ASCENDING/DESCENDING dosen't really change matters. To simplify, sorting the array before presenting it to the datagrid doesn't seem to work. Nor does sorting the datagrid. The sort function does in fact work, because when you click the column header for the age column, it does sort properly, as it only could using that function. I have tried making a special version of the sort function that doesn't have the 3 param signature that sortItems takes, but has only 2 (as Array.sort takes), but that doesn't help either. So the real question is what is the best practice for initializing the sort order of a data grid? Can anyone post a working example? Thanks, -=Cliff --- In flexcoders@yahoogroups.com, Matt Chotin [EMAIL PROTECTED] wrote: I think dg1.sortItems(sortByAge, asc) should have worked (or desc), not Array.ASCENDING and Array.DESCENDING because being consistent with array options would have been too obvious ;-) Haven't tried it though. This will be easier in Flex 2 because sorting will be done through Sort objects and SortFields which the DG will recognize. Matt From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Clifford Hall Sent: Friday, December 30, 2005 10:42 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Custom initial sort on datagrid Hello all, I'm trying to get a datagrid to use a custom sortCompareFunction for its initial sort order. The custom sortCompareFunction works when you click the column header, however attempts to sort the dataprovider before it is assigned or the grid itself after the dataprovider is assigned all fail. The sortCompareFunction has been written so that it can sort either be passed objects as it would on an Array.sort (from which it will retrieve the string for comparison), or strings which the table will pass when the header is clicked. I have reproduced the various attempts to get it to work in a small mxml file included below. There are plenty of comments that show the various places that we may try to effect the sort. If you run this mxml, you'll see the table, and if you click the 'Age' column header, you'll see the sort work. If you are able to shed light on the error of my ways here and make this sort happen, I myself, my children and my chil! dren's children shall speak your name in the most reverant tones for generations to come, perhaps performing a little bedside ritual each night, ordering our pocket change from large to small around the base of the lamp before sleeping as a way of meditating upon the momentous occasion when The Answer was posted and the Great Difficulty passed. Thanks, -=Cliff ?xml version=1.0 encoding=utf-8? !-- Attempt to order the rows of a DataGrid by a column which requires a special sortCompareFunction -- !-- This demo shows that the column (Age) sorts properly when the column header is clicked, -- !-- but attempts to sort the dataprovider or the grid automatically at startup all fail -- !-- Try assigning the dataprovider via binding, and tying a sort at creationComplete -- mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml; creationComp! lete=sortAtCreationComplete() !-- Try assigni! ng the d ataprovider manually at startup, giving the opportunity to force a sort -- !-- mx:Application xmlns:mx=http://www.macromedia.com/2003/mxml; creationComplete=manuallyAssignDP() -- mx:Script ![CDATA[ import mx.utils.ArrayUtil; import mx.utils.Delegate; // sort order lookup hash public var sortOrder:Array; public function sortAtCreationComplete() { // populate the sort order lookup hash sortOrder=getSortOrder(); nb! sp; // try to sort the datagrid // dg1.sortItems(sortByAge,Array.ASCENDING) // try to sort the datagrid's dataprovider dg1.dataProvider.sortItems(sortByAge, Array.ASCENDING) } public function manuallyAssignDP() { // populate the sort order lookup hash sortOrder=getSortOrder(); var da:Array = filterData(); nb! sp; // try sorting the d! ataprovi der before assigning // should work but doesn't // da.sortItems( sortByAge, Array.DESCENDING ); dg1.dataProvider = da; // try sorting the grid // should work but doesn't // dg1.sortItems( sortByAge, Array.DESCENDING ); // ok, grasping at straws, here, // try passing the sort function via delegate doesn't work nb! sp; // var d = new Delegate.create
[flexcoders] Custom initial sort on datagrid
Hello all, I'm trying to get a datagrid to use a custom sortCompareFunction for its initial sort order.The custom sortCompareFunction works when you click the column header, however attempts to sort the dataprovider before it is assigned or the grid itself after the dataprovider is assigned all fail. The sortCompareFunction has been written so that it can sort either be passed objects as it would on an Array.sort (from which it will retrieve the string for comparison), or strings which the table will pass when the header is clicked.I have reproduced the various attempts to get it to work in a small mxml file included below. There are plenty of comments that show the various places that we may try to effect the sort. If you run this mxml, you'll see the table, and if you click the 'Age' column header, you'll see the sort work. If you are able to shed light on the error of my ways here and make this sort happen, I myself, my children and my children's children shall speak your name in the most reverant tones for generations to come, perhaps performing a little bedside ritual each night, ordering our pocket change from large to small around the base of the lamp before sleeping as a way of meditating upon the momentous occasion when The Answer was posted and the Great Difficulty passed.Thanks, -=Cliff?xml version="1.0" encoding="utf-8"?!-- Attempt to order the rows of a DataGrid by a column which requires a special sortCompareFunction --!-- This demo shows that the column (Age) sorts properly when the column header is clicked, --!-- but attempts to sort the dataprovider or the grid automatically at startup all fail --!-- Try assigning the dataprovider via binding, and tying a sort at creationComplete --mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" creationComplete="sortAtCreationComplete()"!-- Try assigning the dataprovider manually at startup, giving the opportunity to force a sort --!-- mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" creationComplete="manuallyAssignDP()" -- mx:Script ![CDATA[ import mx.utils.ArrayUtil; import mx.utils.Delegate; // sort order lookup hash public var sortOrder:Array;public function sortAtCreationComplete() { // populate the sort order lookup hash sortOrder=getSortOrder();// try to sort the datagrid // dg1.sortItems(sortByAge,Array.ASCENDING) // try to sort the datagrid's dataprovider dg1.dataProvider.sortItems(sortByAge, Array.ASCENDING) } public function manuallyAssignDP() { // populate the sort order lookup hash sortOrder=getSortOrder(); var da:Array = filterData();// try sorting the dataprovider before assigning // should work but doesn't // da.sortItems( sortByAge, Array.DESCENDING ); dg1.dataProvider = da;// try sorting the grid // should work but doesn't // dg1.sortItems( sortByAge, Array.DESCENDING ); // ok, grasping at straws, here,// try passing the sort function via delegate doesn't work // var d = new Delegate.create(this, sortByAge); // dg1.sortItems( d, Array.DESCENDING ); // should // would be lovely if we could do this,// since the age column has a sortCompareFunction, // but alas, it never gets called, and the field // is string sorted // dg1.sortItemsBy('age', Array.DESCENDING); } public function filterData():Array { var dp:Array = new Array; dp.addItem( {hi:'abcd', bye:'goodbye', age:'young'} ); dp.addItem( {hi:'efgh', bye:'zoob', age:'younger still'} ); dp.addItem( {hi:'ijkl', bye:'wappa', age:'old'} ); dp.addItem( {hi:'mnop', bye:'grrm', age:'older'} ); dp.addItem( {hi:'qrst', bye:'fluu', age:'young'} ); dp.addItem( {hi:'uvwx', bye:'norb', age:'middle aged'} ); dp.addItem( {hi:'yyzz', bye:'tepid', age:'older yet'} ); dp.addItem( {hi:'AbCd', bye:'wrrr', age:'young'} ); dp.addItem( {hi:'eFgH', bye:'grum', age:'middle aged'} ); dp.addItem( {hi:'IjKl', bye:'quixital', age:'young'} ); dp.addItem( {hi:'mNoP', bye:'snorg', age:'younger'} ); // try sorting the dataprovider here // none of these work, though they should // // dp.sort(sortByAge); // dp.sortItems(sortByAge); // dp.sortItems(sortByAge, Array.DESCENDING);return dp; } private function getSortOrder():Array { var so:Array = new Array(); so['younger still'] = 0; so['younger'] = 1; so['young'] = 2; so['middle aged']= 3; so['old'] = 4; so['older'] = 5; so['older yet']= 6;return so;}public function sortByAge( obj1bject, obj2bject, colIndex:Number ):Number { // depending on whether the method is being called as the// sortCompareFunction of a datagrid column, or as a call from // sortItems on the table or array, it may be passed strings to // compare, or objects from which we get the string, respectively var o1:String; var o2:String; if (obj1.age != undefined) { o1 = obj1.age;o2 = obj2.age; } else {o1 =
[flexcoders] Migrating from Cairngorm 0.95 to 0.99
I'm having some difficulty getting this to happen. I have a prototype app that works using 0.95, and am trying to migrate to 0.99. First, I deployed the cairngorm.swc and cairngorm-manifest.xml to their appropriate locations and edited flex-config.xml to add the new namespace entry. Then I replaced com.iterationtwo with org.nevis throughout the application and replaced the top-level CairngormApplication tag with the ordinary mx:Application tag. Of course a redeploy of everything and a server restart. The error I can't get past is: ---%snip%--- Error /WEB- INF/flex/user_classes/com/mydomain/myapp/view/AppView.mxml:10 Unknown attribute 'view' on com.mydomain.myapp.view.AppViewHelper Error Could not find class 'org.nevis.cairngorm.view.ViewHelper'... ---%snip%--- the line throwing the error is: myView:AppViewHelper id=appViewHelper view={ this } / Has anyone done a doc on migrating to 0.99 yet? Does anyone recognise the above problem from having migrated? -=Cliff -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links * To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] * Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/