18 Replies Latest reply on Oct 24, 2008 6:37 AM by Newsgroup_User

    Attn LuigiL :-)  Problems using Flex Component Kit

    Level 7
      Hi, Luigi;

      I thought I'd appeal to our local Flash Component Kit expert. My end goal
      is to be able to take a 3rd party component that is intended to be used in
      Flash and make it usable in Flex. To this end, I've been trying to use the
      Flex Component Kit to "wrap" this component.

      One problem I have is that my Flex machine had the trial of Flash installed
      on it before Flash was released, so it's not usable with Flash unless I
      totally wipe it. This means that I have to build my swcs in one place and
      transfer them to another. I've seen a couple of hints that maybe the swc
      has to stay where it was built in order to work. This doesn't make any
      sense to me, but maybe it is the root of my problem.

      The first thing I tried was to create a new MC in the Library, drag the 3rd
      party component into it, and convert that to a Flex component. When I put
      the resulting swc in the root of my Flex project, code hinting allows me to
      create <local:Flex3DWall/>, but it won't compile. It gives the error Type
      was not found or was not a compile time constant for Flex3DWall.

      I decided to dial it back and just aim for getting a button in my file. So
      I created a new fla and added a new blank MC and dragged a button into it.
      I converted that to a Flex component and put the resulting swc in the root
      of my project. Then I tried adding <local:TestBtn/> to my Application.
      Again, the code hinting found it no problem, but again it wouldn't compile
      with the error Could not resolve <local:TestBtn> to a component
      implementation.

      Any idea what's going on here?

      Thanks;

      Amy


        • 1. Re: Attn LuigiL :-)  Problems using Flex Component Kit
          Level 7

          "Amy Blankenship" <amySpamFilter@magnolia_pleaseNOspam_multimedia.com> wrote
          in message news:gdli5n$m2a$1@forums.macromedia.com...
          > Hi, Luigi;
          >
          > I thought I'd appeal to our local Flash Component Kit expert. My end goal
          > is to be able to take a 3rd party component that is intended to be used in
          > Flash and make it usable in Flex. To this end, I've been trying to use
          > the Flex Component Kit to "wrap" this component.
          >
          > One problem I have is that my Flex machine had the trial of Flash
          > installed on it before Flash was released, so it's not usable with Flash
          > unless I totally wipe it. This means that I have to build my swcs in one
          > place and transfer them to another. I've seen a couple of hints that
          > maybe the swc has to stay where it was built in order to work. This
          > doesn't make any sense to me, but maybe it is the root of my problem.
          >
          > The first thing I tried was to create a new MC in the Library, drag the
          > 3rd party component into it, and convert that to a Flex component. When I
          > put the resulting swc in the root of my Flex project, code hinting allows
          > me to create <local:Flex3DWall/>, but it won't compile. It gives the
          > error Type was not found or was not a compile time constant for
          > Flex3DWall.
          >
          > I decided to dial it back and just aim for getting a button in my file.
          > So I created a new fla and added a new blank MC and dragged a button into
          > it. I converted that to a Flex component and put the resulting swc in the
          > root of my project. Then I tried adding <local:TestBtn/> to my
          > Application. Again, the code hinting found it no problem, but again it
          > wouldn't compile with the error Could not resolve <local:TestBtn> to a
          > component implementation.
          >
          > Any idea what's going on here?

          Never mind. I figured that since my swcs were in the root, they would
          automatically be in the build path. :-)


          • 2. Re: Attn LuigiL :-)  Problems using Flex Component Kit
            Peter Lorent Level 2
            Amy, sorry I wasn't there to assist you with this but due to the differences in timezone (I'm in the Netherlands) I was most likely having some shuteye. If you still have issues with this, let me know.
            The 3DWall will probably not work when converted to a Flex Component. I've seen some attempts, but I haven't seen it running in a Flex App yet.
            • 3. Re: Attn LuigiL :-)  Problems using Flex Component Kit
              Karl_Sigiscar_1971 Level 3
              I usually add the SWCs resulting from compiling Flex components from Flash CS3 to my Flex project in the lib folder. Another option is to create a swc folder and put all your SWC files in, then edit the project properties and add the path to either the swc/ folder or each SWC file.
              • 4. Re: Attn LuigiL :-)  Problems using Flex Component Kit
                Level 7

                "LuigiL" <webforumsuser@macromedia.com> wrote in message
                news:gdmkmf$65m$1@forums.macromedia.com...
                > Amy, sorry I wasn't there to assist you with this but due to the
                > differences in
                > timezone (I'm in the Netherlands) I was most likely having some shuteye.
                > If you
                > still have issues with this, let me know.
                > The 3DWall will probably not work when converted to a Flex Component. I've
                > seen some attempts, but I haven't seen it running in a Flex App yet.

                That's perfectly ok :-). We all have to sleep sometimes.

                I have a deal with my client that if I get it to work I can share the
                solution, so I'll post back if I do. I'm often too stupid to know what I
                can't do ;-)


                • 6. Re: Attn LuigiL :-)  Problems using Flex Component Kit
                  Level 7

                  "LuigiL" <webforumsuser@macromedia.com> wrote in message
                  news:gdnf3g$c1b$1@forums.macromedia.com...
                  > Good luck then!

                  OK, I'm having another problem. If I give my 3Dwall component in my Flash
                  symbol an instance name so I can control it, I get an error 1120
                  http://bugs.adobe.com/jira/browse/SDK-11360


                  If I create a class file for the symbol and define a public var of type MC
                  for it, I get an error 1151
                  http://curtismorley.com/2008/05/06/flex-flash-error-1151/.

                  If I tell Flash not to declare instances automatically, this compiles, but
                  throws a Type Coercion error 1034 in Flex. If I type the public variable as
                  3Dwall, Flash tells me it expects a semicolon in front of "DWall", perhaps
                  because Types shouldn't begin with numbers? The code assist in Flash offers
                  this as a valid data type, but not Wall3DPro, which is the class the
                  commponent is linked to, according to the linkage.

                  Is there a way to control this guy through AS without giving him an instance
                  name?

                  TIA;

                  Amy


                  • 7. Re: Attn LuigiL :-)  Problems using Flex Component Kit
                    Peter Lorent Level 2
                    No, at least not with the standard workflow 'Convert symbol to Flex Component'. The instance name you assign is used to assign a class to the symbol which is necessary to provide a class that extends UIMovieClip. That is done automatically but - as Peter Ent describes in his example - you can also assign a class yourself. You followed the correct steps:

                    The first thing I tried was to create a new MC in the Library, drag the 3rd
                    party component into it, and convert that to a Flex component.

                    The next to do is what Karl_Sigiscar_1971 describes:
                    I usually add the SWCs resulting from compiling Flex components from Flash CS3 to my Flex project in the lib folder.

                    What I do is right click the Flex Project -> properties -> Flex Build Path -> Library Path -> Add swc
                    and just point to the generated swc

                    If you now get codehinting in the Flex Project, the swc was compiled correctly. If something is wrong with the swc, you'll get a hint like <local:uninitialized

                    I don't have the component in question, but similarly I can't convert the JWPlayer to a Flex Component because of the way that player is initialized. So, maybe that is the case here too, but of course I can't be sure.

                    Grant Skinner came up with another way to use Flash symbols in Flex: http://www.gskinner.com/blog/archives/2007/03/using_flash_sym.html

                    A little bit more involved, but it might give you some extra info on the topic and maybe leads to a solution. Let me know how it works out. Good luck!
                    • 8. Re: Attn LuigiL :-)  Problems using Flex Component Kit
                      Level 7

                      "LuigiL" <webforumsuser@macromedia.com> wrote in message
                      news:gdpbi0$2nj$1@forums.macromedia.com...
                      > No, at least not with the standard workflow 'Convert symbol to Flex
                      > Component'.
                      > The instance name you assign is used to assign a class to the symbol which
                      > is
                      > necessary to provide a class that extends UIMovieClip. That is done
                      > automatically but - as Peter Ent describes in his example - you can also
                      > assign
                      > a class yourself. You followed the correct steps:

                      I think maybe I didn't communicate correctly. I created a new MovieClip
                      that I called FlexWall, and associated that with an as file that extends
                      UIMovieClip. Then I dragged a 3DWall component onto the stage. This all
                      worked (or at least didn't generate any errors but also showed nothing on
                      screen in Flex), but of course I couldn't do anything with that component,
                      because it didn't have an instance name. I named the instance "wall", and
                      that's when I started having the issues.

                      I also had the same problem with naming my button instance in my scaled back
                      button component. I'm thinking there's just something I'm missing about how
                      to use instance names in a class you're going to use for a component--I had
                      this very same issue over a year ago when I was taking CS3 training at
                      Adobe, but to be honest the instructor didn't know Flash very well and
                      couldn't troubleshoot the problem.

                      Unfortunately, this is not spelled out very well in the component
                      documentation, so I think I'm just missing something simple that people who
                      have surmounted it just take for granted.

                      Thanks!

                      Amy


                      • 9. Attn LuigiL :-)  Problems using Flex Component Kit
                        Peter Lorent Level 2
                        Ok. From scratch:
                        Create a new as3 fla file. From the Components view, drag an instance of the 3DWallPro to the stage. Select the instance on the stage and from menu 'Modify', select 'Convert To Symbol' and select Movieclip. Give the symbol an instance name like TheWall (this instance name becomes the identifier in Flex) and set the registration point to the upper left corner. Klik OK. Now select the symbol in the library and from menu 'Commands' select 'Convert symbol to Flex Component'. The output panel will report what has been done to convert the symbol to a Flex Component. Except for the fact that automatically a class has been assigned to the symbol with the name 'TheWall' (or the instance name you assigned in the previous steps).

                        Now when you look at the publish settings -> flash -> AS3 -> settings, check if 'Automatically declare stage instances' is off. OK and close the Publish Settings.

                        Doubleclick the symbol on the stage. Select the instance of the 3DWallPro component. Give it an instance name like 'wall'.

                        Now create a new actionscript class and save it as TheWall.as (remember, the name must match the instance name of the symbol). Make sure it extends UIMovieClip and import mx.flash.UIMovieClip
                        Declare a
                        public var wall:
                        and here you need to assign to correct datatype which is most likely the tricky thing here.
                        You already checked the datatype of the 3DWallPro by checking the linkage. That must be the datatype of the public var wall otherwise you won't have access to the API of the component. Assign the correct datatype. Save the class.
                        Now publish.
                        • 10. Re: Attn LuigiL :-)  Problems using Flex Component Kit
                          Level 7

                          "LuigiL" <webforumsuser@macromedia.com> wrote in message
                          news:gdq4so$61u$1@forums.macromedia.com...
                          > Ok. From scratch:
                          > Create a new as3 fla file. From the Components view, drag an instance of
                          > the
                          > 3DWallPro to the stage. Select the instance on the stage and from menu
                          > 'Modify', select 'Convert To Symbol' and select Movieclip. Give the symbol
                          > an
                          > instance name like TheWall (this instance name becomes the identifier in
                          > Flex)
                          > and set the registration point to the upper left corner. Klik OK. Now
                          > select
                          > the symbol in the library and from menu 'Commands' select 'Convert symbol
                          > to
                          > Flex Component'. The output panel will report what has been done to
                          > convert the
                          > symbol to a Flex Component. Except for the fact that automatically a class
                          > has
                          > been assigned to the symbol with the name 'TheWall' (or the instance name
                          > you
                          > assigned in the previous steps).
                          >
                          > With
                          > Now when you look at the publish settings -> flash -> AS3 -> settings,
                          > check
                          > if 'Automatically declare stage instances' is off. OK and close the
                          > Publish
                          > Settings.
                          >
                          > Doubleclick the symbol on the stage. Select the instance of the 3DWallPro
                          > component. Give it an instance name like 'wall'.
                          >
                          > Now create a new actionscript class and save it as TheWall.as (remember,
                          > the
                          > name must match the instance name of the symbol). Make sure it extends
                          > UIMovieClip and import mx.flash.UIMovieClip
                          > Declare a
                          > public var wall:
                          > and here you need to assign to correct datatype which is most likely the
                          > tricky thing here.
                          > You already checked the datatype of the 3DWallPro by checking the linkage.
                          > That must be the datatype of the public var wall otherwise you won't have
                          > access to the API of the component. Assign the correct datatype. Save the
                          > class.
                          > Now publish.

                          I tried that as well, and it gave me a Type coercion error. It looks like
                          the correct type is _3DWallPro, despite the fact that this isn't referenced
                          anywhere. Or at least the error message in FB says
                          Error #1034: Type Coercion failed: cannot convert _3DWallPro@4d102a9 to
                          Wall3DPro.



                          I'm going to step back and take this from a button and get that working
                          exactly like I want, and hopefully that will shed some light.



                          Thanks again :-)


                          • 11. Re: Attn LuigiL :-)  Problems using Flex Component Kit
                            Peter Lorent Level 2
                            I'm almost tempted to buy the component to try this myself :-).
                            • 12. Re: Attn LuigiL :-)  Problems using Flex Component Kit
                              Level 7

                              "Amy Blankenship" <amySpamFilter@magnolia_pleaseNOspam_multimedia.com> wrote
                              in message news:gdq5kp$76t$1@forums.macromedia.com...
                              >
                              > "LuigiL" <webforumsuser@macromedia.com> wrote in message
                              > news:gdq4so$61u$1@forums.macromedia.com...
                              >> Ok. From scratch:
                              >> Create a new as3 fla file. From the Components view, drag an instance of
                              >> the
                              >> 3DWallPro to the stage. Select the instance on the stage and from menu
                              >> 'Modify', select 'Convert To Symbol' and select Movieclip. Give the
                              >> symbol an
                              >> instance name like TheWall (this instance name becomes the identifier in
                              >> Flex)
                              >> and set the registration point to the upper left corner. Klik OK. Now
                              >> select
                              >> the symbol in the library and from menu 'Commands' select 'Convert symbol
                              >> to
                              >> Flex Component'. The output panel will report what has been done to
                              >> convert the
                              >> symbol to a Flex Component. Except for the fact that automatically a
                              >> class has
                              >> been assigned to the symbol with the name 'TheWall' (or the instance name
                              >> you
                              >> assigned in the previous steps).
                              >>
                              >> With
                              >> Now when you look at the publish settings -> flash -> AS3 -> settings,
                              >> check
                              >> if 'Automatically declare stage instances' is off. OK and close the
                              >> Publish
                              >> Settings.
                              >>
                              >> Doubleclick the symbol on the stage. Select the instance of the 3DWallPro
                              >> component. Give it an instance name like 'wall'.
                              >>
                              >> Now create a new actionscript class and save it as TheWall.as (remember,
                              >> the
                              >> name must match the instance name of the symbol). Make sure it extends
                              >> UIMovieClip and import mx.flash.UIMovieClip
                              >> Declare a
                              >> public var wall:
                              >> and here you need to assign to correct datatype which is most likely the
                              >> tricky thing here.
                              >> You already checked the datatype of the 3DWallPro by checking the
                              >> linkage.
                              >> That must be the datatype of the public var wall otherwise you won't have
                              >> access to the API of the component. Assign the correct datatype. Save the
                              >> class.
                              >> Now publish.
                              >
                              > I tried that as well, and it gave me a Type coercion error. It looks like
                              > the correct type is _3DWallPro, despite the fact that this isn't
                              > referenced anywhere. Or at least the error message in FB says
                              > Error #1034: Type Coercion failed: cannot convert _3DWallPro@4d102a9 to
                              > Wall3DPro.
                              >
                              >
                              >
                              > I'm going to step back and take this from a button and get that working
                              > exactly like I want, and hopefully that will shed some light.

                              OK, I'm a lot closer. I'm still a bit fuzzy on what's going on, but here's
                              what finally maybe got me an inspectable 3DWall in Flex (still nothing
                              visible on stage, but if I can see it in code I'm confident I can get
                              there).

                              New Project>New Symbol (FlexWall)
                              Drag 3Dwall onto stage of FlexWall.
                              Convert FlexWall to Flex component
                              Create FlexWall.as, extending UIMovieClip
                              Change FlexWall baseClass back to MovieClip
                              Change Document class to UIMovieClip
                              Turn off declare instances automatically
                              Turn declare instances automatically back on, and remove the public variable
                              wall from the AS.

                              I'm not sure what combination/sequence of settings worked, since there's a
                              lot of conflicting information out there. I'm going to try to go through
                              all this step by step at some point and write a tutorial, which will
                              hopefully clarify what's going on.

                              Thanks;

                              Amy


                              • 13. Re: Attn LuigiL :-)  Problems using Flex Component Kit
                                Peter Lorent Level 2
                                >>Change Document class to UIMovieClip

                                Hmm, don't know what the effect of that could be. The class that is connected to the symbol is your 'gateway' to the 3DWallPro component. As far as I know the Document Class doesn't affect the published swc. I'm curious what you come up with. So, ultimately you should get a type coercion error when adding the generated component to the application (the famous 'must extend IUIComponent')

                                >>Turn declare instances automatically back on
                                That would be a nice attempt when you can't datatype the public var so you can see what the compiler thinks of the datatype.

                                In the train I thought about this and if I had to try to get this working I would probably try to create a new component in Flash that 'has' an instance of the 3DWallPro component. And ultimately wrap that in a symbol and convert it to a Flex Component. Somehow my feeling is that it needs some kind of 'bridge' to work.
                                • 14. Re: Attn LuigiL :-)  Problems using Flex Component Kit
                                  Peter Lorent Level 2
                                  We are discussing the conversion to a Flex Component but just to be complete on this: using SWFLoader and loading the component as a swf works ok. Thought I needed to mention this.
                                  • 15. Re: Attn LuigiL :-)  Problems using Flex Component Kit
                                    Level 7

                                    "LuigiL" <webforumsuser@macromedia.com> wrote in message
                                    news:gdqk3m$qki$1@forums.macromedia.com...
                                    > We are discussing the conversion to a Flex Component but just to be
                                    > complete on this: using SWFLoader and loading the component as a swf works
                                    > ok. Thought I needed to mention this.

                                    Yes, but I'm very stubborn :-)


                                    • 16. Re: Attn LuigiL :-)  Problems using Flex Component Kit
                                      Level 7

                                      "LuigiL" <webforumsuser@macromedia.com> wrote in message
                                      news:gdqhma$nfp$1@forums.macromedia.com...
                                      >>>Change Document class to UIMovieClip
                                      >
                                      > Hmm, don't know what the effect of that could be. The class that is
                                      > connected
                                      > to the symbol is your 'gateway' to the 3DWallPro component. As far as I
                                      > know
                                      > the Document Class doesn't affect the published swc.

                                      Something I came across somewhere suggested it as a solution to some
                                      problem. Don't remember where/why, but it definitely seems to change the
                                      behavior. I'm not sure I've nailed down the exact cause/effect relationship
                                      of everything.

                                      > I'm curious what you come
                                      > up with. So, ultimately you should get a type coercion error when adding
                                      > the
                                      > generated component to the application (the famous 'must extend
                                      > IUIComponent')

                                      No, since it's extending UIMoviClip, that seems to be ok. It's kind of
                                      aggravating it doesn't support commitProperties...I had to write that back
                                      in.

                                      > >>Turn declare instances automatically back on
                                      > That would be a nice attempt when you can't datatype the public var so you
                                      > can
                                      > see what the compiler thinks of the datatype.
                                      >
                                      > In the train I thought about this and if I had to try to get this working
                                      > I
                                      > would probably try to create a new component in Flash that 'has' an
                                      > instance of
                                      > the 3DWallPro component. And ultimately wrap that in a symbol and convert
                                      > it to
                                      > a Flex Component. Somehow my feeling is that it needs some kind of
                                      > 'bridge' to
                                      > work.

                                      But you ultimately wind up that you have that "has a" thing that you have to
                                      refer to. So if you create a new MC and drag a 3DWall onto the stage, that
                                      MC "has a" 3D wall in it that you need to be able to refer to somehow. If
                                      you make its class file extend UIMovieClip, it "is a" UIMovieClip that "has
                                      a" 3D wall.

                                      The steps above did eventually result in a Flex component that shows the
                                      images in Flex and can be passed a path to the xml and work. The next step
                                      is allowing setting of other properties. I've written a public method on it
                                      that doesn't appear to be visible from Flex.

                                      I'm also getting a problem where it doesn't like my reference to
                                      closeWall(), but I'm sure I'll get there eventually.


                                      • 17. Re: Attn LuigiL :-)  Problems using Flex Component Kit
                                        Peter Lorent Level 2
                                        Great! Then by the end of the day you will have it working :-)
                                        Strange that the Document class has any influence on this. You do mean the Document class of the main timeline in the fla?
                                        • 18. Re: Attn LuigiL :-)  Problems using Flex Component Kit
                                          Level 7

                                          "LuigiL" <webforumsuser@macromedia.com> wrote in message
                                          news:gdrttv$k7n$1@forums.macromedia.com...
                                          > Great! Then by the end of the day you will have it working :-)
                                          > Strange that the Document class has any influence on this. You do mean the
                                          > Document class of the main timeline in the fla?

                                          Yes. I keep getting errors about closeWall() not being defined, even though
                                          I've commented out the reference to it. Very aggravating.