Using External Libraries with Sprouts
Posted by Luke Bayes Wed, 10 Sep 2008 01:26:00 GMT
Sprouts has quite a wide variety of different libraries available that you can instantly include in your project.
as3crypto as3flickrlib-src as3flickrlib as3mapprlib-src as3mapprlib as3syndicationlib-src as3syndicationlib as3youtubelib-src as3youtubelib asunit25 asunit3 bulkloader cairngorm-src cairngorm corelib-src corelib degrafa facebook-api flexlib-src flexlib flexunit-src flexunit fuse papervision swx tweener tweeneras2 yahoomapsas3
You can include any of these libraries by simply adding them as a symbol to your project_model.
1 2 3 4 5 6 7 8 9 | |
This will automatically download and install these libraries into your project and update your compilation tasks to make these targets available!
If you find that the downloaded libraries aren’t working or are out of date, please send us an email with a link to the latest files.
Read on to learn more about packaging up your own libraries!
Of course the first thing everyone wants to know, is how to package up their project as a Sprout library.
It’s still a little bit hacky right now because our implementation only supports external, downloaded libraries – meaning we can’t actually stuff the library code or SWC into the gem – yet. If you’d like to contribute a patch that makes this work, I’ll be forever in your debt!
As it stands right now, you’ll need to post your library to a web server somewhere and add the following to a rakefile:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
That archive_path parameter is a relative target from within your zip archive to the library source path. The folder targeted there will be used to set source_path for the compilers that point at this library.
In the example above, if you extracted the zip file, there would be a directory named ‘src’ that had library source code in it.
If you want to package up your library as a SWC file, just set the archive_path to point directly at the SWC. In the example above, that might be something more like, archive_path: 'bin/coolestever.swc'.
Once you’ve got this all set up, just run rake package.
Thanks to the desc, you should also see a description when you run rake -T.
This task will create a new folder called ‘pkg’ and put a new gem in there. If you publish this gem to RubyForge, and if the name is unused, everyone can get it.
You can also just install the gem manually with gem install pkg/sprout-coolestever-library-0.1.0.gem, and then refer to it in any sprout projects as :coolestever.
Hope this helps someone out there!












