Building for Flex 4.5

334 views
Skip to first unread message

philip

unread,
May 7, 2011, 9:33:08 AM5/7/11
to Granite Data Services Forum
Hi,

Is there any pre-build swc for Flex 4.5? I got the source and tried to
build and get errors.
http://pastebin.com/fqVmVjrS

Thanks, Phil

Robert Zwerus

unread,
May 10, 2011, 4:29:27 AM5/10/11
to gran...@googlegroups.com
I managed to perform some small modifications, which got 2.2.0.SP2 working with Flex SDK 4.5.0.20967.

These are the changes that were necessary (essentially Sort becomes ISort):

$ grep -Rni "// RZ" .
./as3/framework/org/granite/tide/collections/PagedCollection.as:30:    import mx.collections.ISort; // RZ
./as3/framework/org/granite/tide/collections/PagedCollection.as:509:            public override function get sort():ISort { // RZ
./as3/framework/org/granite/tide/collections/PagedCollection.as:515:            public override function set sort(newSort:ISort):void { // RZ
./as3/framework/org/granite/tide/collections/PagedQuery.as:28:    import mx.collections.ISort; // RZ
./as3/framework/org/granite/tide/collections/PagedQuery.as:177:         protected function doFind(filter:Object, first:int, max:int, sort:ISort, findResponder:PagedCollectionResponder):void { // RZ
./as3/framework/org/granite/tide/spring/PagedQuery.as:28:    import mx.collections.ISort; // RZ
./as3/framework/org/granite/tide/spring/PagedQuery.as:88:               protected override function doFind(filter:Object, first:int, max:int, sort:ISort, findResponder:PagedCollectionResponder):void { // RZ

wdrai

unread,
May 10, 2011, 5:01:45 AM5/10/11
to gran...@googlegroups.com
Correct. 
For now we cannot commit this fix because it would break the build with older versions of the Flex SDK. 
We have yet to find how to avoid having two different swcs (granite.swc and granite45.swc), anyone having an idea of how to do this is welcome...

Kris Hofmans

unread,
May 10, 2011, 5:13:11 AM5/10/11
to gran...@googlegroups.com
Hi,

You can use the FlexVersion class:

if (FlexVersion.CURRENT_VERSION == FlexVersion.VERSION_4_5)
{
    // do stuff for 4.5
}
else
{
    // stuff for older versions
}

It includes constants for all versions.

Now with all the imports and stuff it gets a bit tricky, you'il have to get creative with include I guess.

wdrai

unread,
May 10, 2011, 5:32:33 AM5/10/11
to gran...@googlegroups.com
This is trickier because the Flex API itself has changed and PagedCollection must override get sort() (and it cannot override both the old get sort and the new get sort).
I fear we will have to release a granite-4.5.swc.

philip

unread,
May 10, 2011, 6:36:20 AM5/10/11
to Granite Data Services Forum
Hi Robert,

Thanks for the change information, yes I also noticed the ISort a few
days ago and built mine and it worked, I'll look at your other changes
and see if I need to bring them in.

I need to stay on the cutting edge, 4.5 is essential.

Phil

Robert Zwerus

unread,
May 10, 2011, 7:19:01 AM5/10/11
to gran...@googlegroups.com
It might be possible to use conditional compilation for this:
http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_21.html

philip

unread,
May 10, 2011, 9:18:06 AM5/10/11
to Granite Data Services Forum
error at runtime.

Error: Items pending from 0 to 120 for index 60
at org.granite.tide.collections::PagedCollection/getItemAt()[C:
\software\graniteds-2.2.0.SP2 nightly build\graniteds\as3\framework\org
\granite\tide\collections\PagedCollection.as:695]
at mx.collections::ListCollectionView/http://www.adobe.com/2006/
actionscript/flash/proxy::nextValue()[E:\dev\hero_private\frameworks
\projects\framework\src\mx\collections\ListCollectionView.as:962]
at com.flexicious.grids::ExtendedDataGrid/
setColumnWidthsUsingWidthMode()[C:\code\Flexicious\FlexGrid\includes
\GridInclude.as:216]
at com.flexicious.grids::ExtendedDataGrid/commitProperties()[C:\code
\Flexicious\FlexGrid\src\com\flexicious\grids\ExtendedDataGrid.as:323]
at mx.core::UIComponent/validateProperties()[E:\dev\hero_private
\frameworks\projects\framework\src\mx\core\UIComponent.as:8209]
at mx.managers::LayoutManager/validateProperties()[E:\dev\hero_private
\frameworks\projects\framework\src\mx\managers\LayoutManager.as:597]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev
\hero_private\frameworks\projects\framework\src\mx\managers
\LayoutManager.as:813]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev
\hero_private\frameworks\projects\framework\src\mx\managers
\LayoutManager.as:1180]

philip

unread,
May 10, 2011, 9:41:51 AM5/10/11
to Granite Data Services Forum
Seems that this is a good error, not a bad error.

Robert Zwerus

unread,
Jun 17, 2011, 5:20:26 AM6/17/11
to Granite Data Services Forum
I spent some time trying to get it to work. It works, but the check
for the SDK version in build.xml is not complete (for now it only
checks the SDK's build number, as I couldn't get it to compare
strings: ${flex-sdk-description.version}==4.5.0).

diff -ur graniteds/as3/framework/org/granite/tide/collections/
PagedCollection.as modifiedgraniteds/as3/framework/org/granite/tide/
collections/PagedCollection.as
--- graniteds/as3/framework/org/granite/tide/collections/
PagedCollection.as 2011-06-14 14:50:48.000000000 +0200
+++ modifiedgraniteds/as3/framework/org/granite/tide/collections/
PagedCollection.as 2011-06-17 10:58:47.000000000 +0200
@@ -30,6 +30,7 @@
import mx.collections.IViewCursor;
import mx.collections.ListCollectionView;
import mx.collections.Sort;
+ import mx.collections.ISort;
import mx.collections.SortField;
import mx.collections.errors.ItemPendingError;
import mx.core.IPropertyChangeNotifier;
@@ -505,12 +506,22 @@
}

[Bindable("sortChanged")]
+ CONFIG::flex_sdk_4
public override function get sort():Sort {
if (_tempSort && !_tempSort.sorted)
return _tempSort;
return super.sort;
}
-
+
+ [Bindable("sortChanged")]
+ CONFIG::flex_sdk_45
+ public override function get sort():ISort {
+ if (_tempSort && !_tempSort.sorted)
+ return _tempSort;
+ return super.sort;
+ }
+
+ CONFIG::flex_sdk_4
public override function set sort(newSort:Sort):void {
// Track changes on sort fields
if (sort != null && sort.fields != null) {
@@ -521,6 +532,17 @@
super.sort = newSort;
}

+ CONFIG::flex_sdk_45
+ public override function set sort(newSort:ISort):void
{
+ // Track changes on sort fields
+ if (sort != null && sort.fields != null) {
+ for each (var field:SortField in
sort.fields)
+
field.removeEventListener("descendingChanged",
sortFieldChangeHandler);
+ }
+ _sortFieldListenersSet = 0;
+ super.sort = newSort;
+ }
+

/**
* @private
diff -ur graniteds/as3/framework/org/granite/tide/collections/
PagedQuery.as modifiedgraniteds/as3/framework/org/granite/tide/
collections/PagedQuery.as
--- graniteds/as3/framework/org/granite/tide/collections/
PagedQuery.as 2011-06-14 14:50:34.000000000 +0200
+++ modifiedgraniteds/as3/framework/org/granite/tide/collections/
PagedQuery.as 2011-06-17 11:13:09.000000000 +0200
@@ -27,6 +27,7 @@
import mx.collections.IList;
import mx.collections.ListCollectionView;
import mx.collections.Sort;
+ import mx.collections.ISort;
import mx.collections.SortField;
import mx.collections.errors.ItemPendingError;
import mx.core.IPropertyChangeNotifier;
@@ -173,6 +174,7 @@
doFind(filter, first, max, sort,
findResponder);
}

+ CONFIG::flex_sdk_4
protected function doFind(filter:Object, first:int,
max:int, sort:Sort, findResponder:PagedCollectionResponder):void {
// Force evaluation of max, results and count
var order:* = null;
@@ -200,6 +202,35 @@
findResponder]
);
}
+
+ CONFIG::flex_sdk_45
+ protected function doFind(filter:Object, first:int,
max:int, sort:ISort, findResponder:PagedCollectionResponder):void {
+ // Force evaluation of max, results and count
+ var order:* = null;
+ var desc:* = null;
+ if (this.multipleSort) {
+ if (sort != null) {
+ order = new Array();
+ desc = new Array();
+ for each (var s:SortField in
sort.fields) {
+ order.push(s.name);
+
desc.push(s.descending);
+ }
+ }
+ }
+ else {
+ order = sort != null &&
sort.fields.length > 0 ? sort.fields[0].name : null;
+ desc = sort != null &&
sort.fields.length > 0 ? sort.fields[0].descending : false;
+ }
+
+ _context.meta_callComponent(_component,
_methodName, [filter,
+ first,
+ max,
+ order,
+ desc,
+ findResponder]
+ );
+ }


protected override function
getResult(event:TideResultEvent, first:int, max:int):Object {
diff -ur graniteds/as3/framework/org/granite/tide/spring/PagedQuery.as
modifiedgraniteds/as3/framework/org/granite/tide/spring/PagedQuery.as
--- graniteds/as3/framework/org/granite/tide/spring/
PagedQuery.as 2011-06-14 14:50:38.000000000 +0200
+++ modifiedgraniteds/as3/framework/org/granite/tide/spring/
PagedQuery.as 2011-06-17 11:13:49.000000000 +0200
@@ -27,6 +27,7 @@
import mx.collections.IList;
import mx.collections.ListCollectionView;
import mx.collections.Sort;
+ import mx.collections.ISort;
import mx.collections.SortField;
import mx.collections.errors.ItemPendingError;
import mx.core.IPropertyChangeNotifier;
@@ -83,7 +84,7 @@
_methodName = "list";
}

-
+ CONFIG::flex_sdk_4
protected override function doFind(filter:Object,
first:int, max:int, sort:Sort,
findResponder:PagedCollectionResponder):void {
var order:* = null;
var desc:* = null;
@@ -129,6 +130,53 @@
super.doFind(filter, first, max, sort,
findResponder);
}
}
+
+ CONFIG::flex_sdk_45
+ protected override function doFind(filter:Object,
first:int, max:int, sort:ISort,
findResponder:PagedCollectionResponder):void {
+ var order:* = null;
+ var desc:* = null;
+ if (this.multipleSort && !
_useGrailsController) {
+ if (sort != null) {
+ order = new Array();
+ desc = new Array();
+ for each (var s:SortField in
sort.fields) {
+ order.push(s.name);
+
desc.push(s.descending);
+ }
+ }
+ }
+ else {
+ order = sort != null &&
sort.fields.length > 0 ? sort.fields[0].name : null;
+ desc = sort != null &&
sort.fields.length > 0 ? sort.fields[0].descending : false;
+ }
+
+ if (_useGrailsController) {
+
_context.meta_callComponent(_component, _methodName, [{ filter:
filter,
+ offset: first,
+ max: max,
+ sort: order,
+ order: desc ? "desc" :
"asc"
+ },
+ true, // Use local binding
+ findResponder]
+ );
+ return;
+ }
+ else if (_useController) {
+
_context.meta_callComponent(_component, _methodName, [{ filter:
filter,
+ first: first,
+ max: max,
+ order: order,
+ desc: desc
+ },
+ true, // Use local binding
+ findResponder]
+ );
+ }
+ else {
+ super.doFind(filter, first, max, sort,
findResponder);
+ }
+ }


protected override function
getResult(event:TideResultEvent, first:int, max:int):Object {
diff -ur graniteds/build.xml modifiedgraniteds/build.xml
--- graniteds/build.xml 2011-06-14 14:50:34.000000000 +0200
+++ modifiedgraniteds/build.xml 2011-06-17 11:12:18.000000000 +0200
@@ -1243,7 +1243,7 @@
<target name="build.swc" depends="check.swc" unless="skip.compc">
<mkdir dir="build"/>
<mkdir dir="build/META-INF"/>
-
+
<!-- Create Swcs Manifest -->
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss
'GMT'Z"/>
@@ -1267,6 +1267,8 @@
<zip basedir="build" update="true" keepcompression="true"
destfile="build/granite-essentials.swc" includes="META-
INF/MANIFEST.MF"/>

+ <xmlproperty file="${FLEX_HOME}/flex-sdk-
description.xml"/>
+
<compc output="build/granite.swc" use-network="false" warn-
missing-namespace-decl="false">
<source-path path-element="as3/framework"/>
<include-sources dir="as3/framework" includes="**/*.as"/>
@@ -1276,7 +1278,9 @@
<compiler.library-path dir="build" append="true">
<include name="granite-essentials.swc" />
</compiler.library-path>
- <define name="CONFIG::debugging" value="false"/>
+ <define name="CONFIG::debugging" value="false"/
>
+ <define name="CONFIG::flex_sdk_45" value="$
{flex-sdk-description.build} >= 20967"/>
+ <define name="CONFIG::flex_sdk_4" value="!
CONFIG::flex_sdk_45"/>
</compc>
<zip basedir="build" update="true" keepcompression="true"
destfile="build/granite.swc" includes="META-INF/
MANIFEST.MF"/>
Reply all
Reply to author
Forward
0 new messages