6 Replies Latest reply on Apr 26, 2009 4:28 AM by wvxvw

    How do I import SWC files created with Flex info Flash CS4?

    v.karailiev Level 1

      I've created very nice UI component using Flex 3 and I have exported it into a SWC file.

      How can I import it into Flash CS4 to use it there?

        • 1. Re: How do I import SWC files created with Flex info Flash CS4?
          Michael Borbor Level 4

          There's an article at Adobe Devnet named Code in Flex, Test in Flash

          that might help you.

           

          Sincerely,

           

          Michael

          • 2. Re: How do I import SWC files created with Flex info Flash CS4?
            wvxvw

            If it doesn't depend on framework.swc or flex.swc there should be no problem, only make sure you have manifest.xml file with the declaration of your component and set -digest to false when compiling SWC. Besides, the component should extend Sprite directly or indirectly.

            But if it does depend on framework.swc or flex.swc, then, probably, there's no easy way to do it... more preciesly, no easy way to use it after you import it into Flash... this is because components which extend mx.core.UIComponent have to be instantiated and managed by other Flex classes.

            • 3. Re: How do I import SWC files created with Flex info Flash CS4?
              v.karailiev Level 1

              I've followed this instructions: http://www.adobe.com/devnet/flash/articles/flex_to_flash_03.html

              When I try to start the Flash application I get this message:

              Error: No class registered for interface 'mx.styles::IStyleManager2'.
                  at mx.core::Singleton$/getInstance()
                  at mx.styles::StyleManager$/get impl()
                  at mx.styles::StyleManager$/isInheritingStyle()
                  at mx.core::UIComponent/setStyle()
                  at Te()
                  at Untitled_fla::MainTimeline/frame1()

               

              Any ideas?

              • 4. Re: How do I import SWC files created with Flex info Flash CS4?
                wvxvw Level 1

                Well, as I said, if your component is in the framework.swc dependencies you will have a lot of troubles using it in Flash. Honestly, I'd give it up. It would be much faster to refactor your component to not to use framework than to try to fight this issue... Because if you want to solve this you need the container that will be hosting your component to implement ISystemManager, this will force you to bring into your project some 30-50 more classes and actually implement that interface (that'd in total would be more than 1K lines of code not including comments Besides, your SWF will grow in size by 50K... I'm really not sure you want this

                • 5. Re: How do I import SWC files created with Flex info Flash CS4?
                  v.karailiev Level 1

                  You are right - it's getting too complicated.

                  Is there some source to read about cross platform (Flash/Flex/Air) programming?

                  I'm familiar with Flex, the component is working fine in Air, but all this with movie clips, sprites and shapes is really new for me.

                  • 6. Re: How do I import SWC files created with Flex info Flash CS4?
                    wvxvw Level 1

                    Hmm... if you happen to be familiar with C#, then you may probably know about the problem of P/Invoke (this is a command that lets you access Windows API through C# code, which will apparently prevent it from functioning on other OSs).

                    What happens with Flex framework is somewhat similar to this. I.e. it relies to much on the features of Flex compiler and the components of the framework create a lot of cross-dependencies, which makes them barely usable outside the framework.

                     

                    So, if you have time and doing this just as a matter of learning, I'd suggest you start an AS project in Flex builder and advance with it compiling it both with Flex and Flash to see if there are any differences (basically, once you see it doesn't compile / doesn't behave as you'd expect in Flash, you'll know you used something that is specific to Flex). These would be mostly meta tags, like [Bindable] for example.

                    And, if you need any tutorials on how to code in pure AS, then, well, there are really to many So that you can even choose what's appropriate / goes better with your learning habits.

                    If you like video lessons, there're tons of them at gotoandlearn.com, if you prefer reading documentation, here you go: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/class-summary.html

                    if you prefer forums / written tuts, then, kirupa.com, actionscript.org, flashkit.com as well as Adobe forums will provide you with a lot of information.