AdvancedDataGrid & flexdatavis a love story

15 views
Skip to first unread message

Carlos Ríos V.

unread,
Oct 6, 2011, 2:04:24 AM10/6/11
to ProjectSprouts, slar...@gmail.com
Hello ProjectSprouts people!

I'm a programmer who is starting to learn Flex (version 3) and uses
GNU/Linux for everything, so I was pointed to this project to be able
to code in Flex under Linux.

I got a code in Flex that I wanted to migrate to Sprouts, everything
went ok until rake. I was getting this error:

[ERROR] /home/crosvera/programming/e2i/e2iavl-webclient/src/
dashboard.mxml(837): Error: Could not resolve <mx:AdvancedDataGrid> to
a component implementation.

Surfing the web I found that I needed to include "The Data
Visualization Components" [1] to my project, and I fount that
flexdatavis does the job for me.

In [2] and [3] , says that I need to add an entry in Gemfile:

gem "sprout-flexdatavis-library", ">= 3.4.1"

And also add an entries in Rakefile:

library :flexdatavis
mxmlc 'bin/SomeProjectRunner.swf' => :flexdatavis do |t|
...
end


After doing that, I proceed to 'bundle install', everything ok, sprout-
flexdatavis-library got installed. Then I ran 'rake' and I got:

Could not load the required file (flexdatavis) - Maybe you need to
run 'gem install flexdatavis' or maybe 'bundle install'?

After several hours, I found that if I copy the 'frameworks' folder
contained in [4] into ~/.sprouts/1.1/cache/flex3/1.0.29.pre/ and
undoing the modifications made in Gemfile and Rakefile, the project
compiled.


Why the flexdatavis didn't work? is it a bug?

I hope this information helps others with the same problem.

Regards

PS: Sorry for my English.

[1] http://shashankkulkarni.com/2010/07/16/could-not-resolve-to-a-component-implementation-simple-solution-steps/

[2] http://projectsprouts.org/docs/1.1/FlashSDK.html (Library Section)

[3] http://groups.google.com/group/projectsprouts/browse_thread/thread/d6c85ea045d40622/5fa020f2e816404f

[4] http://download.macromedia.com/pub/flex/sdk/datavisualization_sdk3.4.zip

Luke Bayes

unread,
Oct 6, 2011, 2:15:14 PM10/6/11
to project...@googlegroups.com, slar...@gmail.com
Hey Carlos,

Thanks so much for the detailed question, and for working through (and sharing) the solution.

You've bumped into something that is definitely confusing, and based on your description, I'm not exactly sure why it's working at this point. I'll do my best to explain the parts I understand, and hopefully that'll help us both figure out why it's working.

The first issue is the Gemfile.

One of the main design changes in the new Sprouts, is that everything is fundamentally, basically Ruby and nothing in the core reaches out and depends on (or manipulates) RubyGems. That said, RubyGems (and Gem Bundler) are reasonably clean tools for getting new, external Ruby code into your currently-running virtual machine.

So, if you have some Ruby code (like a Sprout spec, or other Sprout tools), that is available as a RubyGem, you can make that code available to your project by adding a reference to it's name to your Gemfile. Once that code has been made available, you'll need to do something that actually loads it.

This is where the 'library' statement comes in. Deep in the implementation of the 'library' statement, Sprouts will first attempt to load the registered library with the provided name, and if one is not registered, it will attempt to 'require' a Ruby file with the optionally-provided 'pkg_name'. If no 'pkg_name' is provided, it will use the library name itself. This is probably the most confusing part of this story.

This line:

   library :flexdatavis

Will ultimately turn into this:

   require 'flexdatavis'

But if there's no file like, 'flexdatavis.rb' in your load path, then you'll get an error like:

   Could not load the required file (flexdatavis) - Maybe you need to
   run 'gem install flexdatavis' or maybe 'bundle install'?

That require statement will not be executed if some Ruby file has already been loaded that does something like this:

   Sprout::Library.register :name => :flexdatavis, :path => '/path/to/lib.swc'

This work is actually performed by the Sprout::Specification 'add_library' method, and it is usually done after a Sprout::Specification is made available by RubyGems, and subsequently required at the top of a Rakefile.

Given all of that, I'm not exactly sure how the datavis source ended up in your project load path without something like the following:

A Sprout::Specification that registers the swc under a given alias like:

   t.add_library :flexdatavis, "frameworks/blah/blah.swc"

Followed by the declaration and addition of the library dependency to an mxmlc task like:

   library :flexdatavis

   mxmlc 'foo.swf' => :flexdatavis


In order to avoid all of this hassle for libraries that aren't included in a Sprout::Specification,  you can easily, manually add any source or SWC files to a folder of your choice in your project, and manually add them to your tasks like:

    mxmlc 'foo.swf' do |t|
      t.library_path << 'relative/path/to.swc'
    end

Or:

    mxmlc 'foo.swf' do |t|
      t.source_path << 'relative/path/to/source'
    end


I suspect one of two following options has happened to get you unblocked:

1) Updating the flex frameworks folder clobbered the usual framework SWC with one that includes the datavis components and therefore doesn't require any changes to the load path.

2) One of the previous steps copied the datavis SWC into your project 'lib' path, and you're auto-including everything that's in that folder.


Thanks again!

Luke




--
You received this message because you are subscribed to the Google Groups "ProjectSprouts" group.
To post to this group, send email to project...@googlegroups.com
To unsubscribe from this group, send email to projectsprout...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/projectsprouts?hl=en

For other info you can visit our project at: http://projectsprouts.org, or on Github at: http://github.com/lukebayes/project-sprouts

Reply all
Reply to author
Forward
0 new messages