Select to view content in your preferred language

Can agslib be used in a flex library project?

928
4
02-03-2011 11:11 AM
JerryEla
Emerging Contributor
I am trying to build some components based on agslib 2.2.  I want to build them in a flex library so they can be used with multiple apps.  But I get run time errors with code that runs fine if it is in the main project, if I move it to a library.  A simple test case.

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:esri="http://www.esri.com/2008/ags"
pageTitle="GISLib ET" xmlns:view="view.*" >
 
<view:MapTest/>
 
</s:Application>

MapTest
<esri:Map xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
        xmlns:esri="http://www.esri.com/2008/ags">


<esri:ArcGISDynamicMapServiceLayer
  url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/BloomfieldHillsMichigan/Parcels/MapServer"/>

</esri:Map>

This runs fine if the view package is in the main project file, but fails with a runtime error.  But if the view package is in a library swc the code fails with a run time error.

ApplicationSkin2._ApplicationSkin_Group1.contentGroup.MapTest5.StaticLayer9.ScaleBar12 cannot be found.

Am I missing something?
Tags (2)
0 Kudos
4 Replies
ReneRubalcava
Esri Frequent Contributor
I maintain a library using the ESRI Flex API and I know that error all too well.
Granted, this error will ONLY occur in Flex/FlashBuilder, I can successfully link my library files in IntelliJ and FDT withouth issue. Go figure.
Anyway, in the Properties for your main project, add your library file (Add Project), make sure Link Type is RSL (runtime shared library).

FlashBuilder will compile and link to the library swf.
Now, here is the kicker. If you make any changes to your library file at all that force it to rebuild, you will need to remove the library project from your Main project and re-add it following the steps above.
You'll need to do this every single time you update your library project.
It's a horrible workaround, but I do it on a daily basis. I am really not a fan of Flashbuilder at all.
0 Kudos
JerryEla
Emerging Contributor
Thanks, that worked.  I use swcs a lot and have never seen that problem.  I wonder what it is about agslib that FlashBuilder doesn't like.
0 Kudos
DasaPaddock
Esri Regular Contributor
Have you tried making like link type for the ArcGIS Flex API swc "External" in your library project? This way it won't try to copy what it thinks it needs from the ArcGIS Flex API swc into your swc. Then in your app project you'll need to add both your swc and the ArcGIS Flex API swc to your project.
0 Kudos
JerryEla
Emerging Contributor
External does seem to work. 

Setting it to RSL had been working fine for a couple of days, and suddenly I started getting the error again.  Removing and readding the lib as suggested by odoe wasn't fixing it either.

Hopefully external will continue to work.
0 Kudos