Flash CS3 has the fl package. Flex Builder and the Flex SDK have the mx libraries. I’m writing code that I wish to be able to compile in Flash and Flex. That means, I need to implement one system that determines whether the program was written in Flash or Flex, and another system that can import from the fl package or the mx package.
I’ve got the first system working, which is cool. Flex has an [Embed] tag that Flash CS3 ignores, so it’s pretty easy to write a function that finds out whether it was compiled in Flash CS3 or Flex. But I’m stumped on the second system. I thought I could use getDefinitionByName() to “dynamically import” fl and mx classes, but it seems that, unless I have code somewhere that explicitly imports these classes, getDefinitionByName() won’t find a public definition for any class in either package.
Does anyone have any ideas for ways to import an fl class in Flash or an mx class in Flex with the same code? Assume that Flash CS3 has Strict Mode turned on.
Flex and Flash can import from all those libraries assuming you have both the Flash IDE and the flex SDK installed. Not sure why you would need two alternative swfs.
The motivation behind this is, I’m developing an open source project that I’d like to give out to anyone who knows AS3, regardless of their favorite IDE. So ideally I’d like to give Flash devs and Flex devs the same code, and it would compile and run without a hitch in both environments with no changes. So there aren’t alternative SWFs, just alternative build processes, which throw different errors and support different packages.
Speaking of which, juggler, do you mean to say that you can use the mx package in Flash CS3, and the fl package with the Flex SDK? I would very much like to know how you achieved that. Keep in mind, though, that I’m looking for a solution for folks who only have one of these programs (though requiring an installation of the Flex SDK, being free and all, is not too big a hassle).
The flex SDK is free to download, so if you are using Flash IDE you can link to that library in … i think the project properties? You obviously can’t write MXML, but i am fairly sure you can use the mx classes. I have to admit i haven’t tested this though.
And for flex you can use the fl. classes by adding that library in the project properties panel, but you need to own the flash ide to have them in the first place so that’s kind of irrelevant i guess.
I just don’t know how you can expect people using just flash to be able to work cooperatively with people using flex. The compatibility issues make my mind hurt. Maybe just say everyone should use the FlashDevelop (free) IDE and use the free Flex SDK? That way everyone is in the same environment, and it’s a really good one.
Fortunately, the only fl and mx dependencies I have are the tween easing functions. I’m using Flash CS3 to develop the project, and there are library assets in an FLA file that certainly aren’t editable by any Flex dev. But I’m thinking of compiling those assets into a SWF, whose classes can be accessed at compile time through embedding.
I’ve also programmed this thing to run successfully as an AIR app or a SWF file. 
I suppose I could just make my own easing function classes. That’d make the most sense, wouldn’t it? The package dependencies would pretty much evaporate at that point.
Either that or use one of the open source tween libraries available, which are actually tons better than the built in ones anyway. Have a look at Tweener and Tweenlite.
http://code.google.com/p/tweener/
http://blog.greensock.com/tweenliteas3/
Right, I’m using TweenLite. But it has no easing function library, you know? It expects us to use the built-ins or something. Is there a (comprehensive) easing function library that you’d suggest?
caurina Tweener has easing functions built in
I just discovered Robert Penner’s easing classes. Looks pretty extensive. I think I’ll use these.
Thanks for your help, folks! 