tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/155-compiling-with-selected-libsRobotlegs: Discussion 2018-10-18T16:35:12Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/16398102010-05-10T08:24:34Z2010-05-10T08:24:34Zcompiling with selected libs<div><p>I think you actually need conditional compiling variables.</p>
<p>They look like CONFIG::IncLIb1 and the code contained within the
if() statements that depend on them only runs through the compiler
if they're true (or the correct case).</p>
<p>Rather than specify it in the Api they'd have to specify it in
the compiler variables - can be done in Flash, Flex, Flash Builder
or command line compiling. If you wanted to double lock it (avoid
newbie errors) you could also specify it in the Api init() and
cross check the two.</p>
<p>I generally use it for testing / isolating Air vs Swf
functionality etc, but I'm pretty sure it would work in this way
too.</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/16398102010-05-10T17:04:13Z2010-05-10T17:04:13Zcompiling with selected libs<div><p>thanks stray.</p>
<p>i thought about conditional compilation but decided it's not a
good option for my users, many of whom are relatively novice. i'm
looking for a solution that is entirely actionscript. that's what
led me here, but perhaps i was misled....?</p>
<p>your suggestion about double-checking on init and throwing a
descriptive error is an interesting one, though.</p>
<p>-eric</p></div>eric socolofskytag:robotlegs.tenderapp.com,2009-10-18:Comment/16398102010-05-11T10:04:43Z2010-05-11T10:04:43Zcompiling with selected libs<div><p>Hi Eric,</p>
<p>unfortunately I don't think there's another option. If you
include a type in a class document, and the class is not found,
then the compiler will error.</p>
<p>The only way around it is conditional compiling, or possibly a
major tinkering with the flex compiler config, but that's even more
technical.</p>
<p>If your users are novice, are they using flash? Flash has a GUI
for adding compiler vars. It's not very technical and would be easy
to visually guide your users through. All they'd have to do is list
out your swcs and put TRUE or FALSE against each of them.</p>
<p>The easiest way to do that would be to provide a CS4 Fla with
the key data already set up, they'd then just have to set to 'TRUE'
the libraries that they did have access to. Anyone who can write an
event handler would be able to do that I'm sure.</p>
<p>IOC / DI isn't a conditional compiling solution - it's a way of
providing classes with what they need at runtime without having to
pass objects all over the place or make everything a Singleton. So,
unfortunately Robotlegs can't help you with this one...</p>
<p>(I could be wrong - anyone got an alternative thought?)</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/16398102010-05-11T10:22:06Z2010-05-11T10:22:06Zcompiling with selected libs<div><p>I think Stray is completely right about this.</p>
<p>Maybe another solution would be to use interfaces for the<br>
interchangeable parts throughout your application and implement
some<br>
kind of factory that loads one of the actual implementations, based
on<br>
the runtime configuration.</p>
<p>This factory would then need to encapsulate not only the<br>
implementation's loading, but also the entire instance
construction<br>
and all.</p>
<p>Thinking about this, you might even be able to encapsulate the
entire<br>
process in SWCs: Each SWC contains one of the libraries and exposes
a<br>
class (let's call it "LibraryFactory"), using which you can get
access<br>
to the library.</p>
<p>Each developer simply adds the library they have access to to
their<br>
library path and the application just uses the LibraryFactory
to<br>
instantiate whichever class the compiler finds under that name.</p>
<p>Of course, this scheme falls apart as soon as a developer has
access<br>
to, and wants to use, more than one of the libraries. Also, it
would<br>
run into problems if there's ever a situation where two or more<br>
modules using this setup and different libraries are loaded into
the<br>
same player instance.</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/16398102010-05-11T16:42:31Z2010-05-11T16:42:31Zcompiling with selected libs<div><p>thanks all.</p>
<p>stray, thanks for the responses and clarification on
robotlegs.</p>
<p>tschneidereit, the problem with your suggestion, as you mention,
is with access to more than one library -- that's at the core of my
problem, and shown in my initial example...the more i think about
it, the more it makes sense that the compiler can't know which
classes to compile if a class reference is dynamically composed
(from a string).</p>
<p>i've experimented with a solution that works, but it not pretty
-- built my SWCs into SWFs, load them at runtime, and pull the
needed classes out of the loaded SWFs. however, there is no type
safety in this. i'm not sure yet how much that matters, since my
API will be abstracting away all direct calls to those
libraries.</p>
<p>i'm beginning to think i'll just have to expose my newbie devs
to conditional compiling, and provide examples/bootstraps to make
it as painless as possible. hm.</p>
<p>cheers<br>
-eric</p></div>eric socolofskytag:robotlegs.tenderapp.com,2009-10-18:Comment/16398102010-05-11T18:26:53Z2010-05-11T18:26:53Zcompiling with selected libs<div><p>The following message to <a>levi.strope@ecommerce.com</a> was
undeliverable.<br>
The reason for the problem:<br>
5.1.0 - Unknown address error 550-'sorry, no mailbox here by that
name (#5.1.1)'</p></div>Mail Delivery System