PDA

View Full Version : Creating a Library in Flex and using it in flash CS4


}{ermanssoN
01-14-2009, 06:02 PM
Hello.

I'm would like to know if there if there is a way to write a couple of AS classes in flex. Compile those classes into a library and then import them in Flash CS4.
Kind of like link to a .lib in C++.

For example I would like to create a geometry manager class that can perform calculations on various objects such as a box class, wich I'l also implement as a part of the library. Then in Flash CS4 after importing the library, I could in the timline just create a box and a geometry manager instance.

//}{ermanssoN

Sekhar
01-14-2009, 08:07 PM
Check out this blog (http://labs.wichers.nu/2007/12/25/using-flex-compiled-code-within-flash/).

}{ermanssoN
01-15-2009, 05:44 AM
Thnx. I did not fully understand all of his explonations but it seems possible.
I did not how ever like the fact that your imported code is stored inside a movieclip.

so there is no way to just load and swc in your code and them use it's classes?

}{ermanssoN
01-15-2009, 06:13 PM
I soulved it on a very very easy way.

1 Create a new project i Flex library project
2.Create a class that has a public fuction Print().
3: make print do: trace("doedlido");
4. genrate the swc file

5.open flash CS 4
6. File -> Publish Settings -> Flash -> Settings -> Library path -> Browse to SWC file. Brows to your swc file
7. in the timeline create a instance of your class. Call the function Print();
8. Check the output for "doelido"

You can now do most of yor flash coding in the very nice Eclipse ide!

in C3:
1. Program Files\Adobe\Adobe Flash CS3\{lang}\Configuration\Components\paste your swc here
2.Open Flash IDE and select on the Component Panels (Windows -> Components) the Options menu to refresh its view ("Reload"). your swc should apear in the Component panel. Darg it in to your stage. you may then remove it from the stage. when you draged it to the stage all code became availble.

Note I have only tested it for flash CS4

Sekhar
01-15-2009, 06:47 PM
Yeah, but isn't that what the blog suggested? Create an SWC in Flex and access from Flash. The net I got from the blog is you can't access the Flex libs directly in Flash, but you can do it via a Flex app.

}{ermanssoN
01-16-2009, 10:51 AM
well since I use cs4 i didn't get his example to work. after finding one for flash cs4 i understod what he meant. My steptrough seems easier to follow, atleast in my head^^.
And as I said, he didn't show you how to do it in CS4