4 Replies Latest reply on Jun 16, 2008 3:19 PM by Dtancredi

    swc / accordion problem, trying to create a 3-level dynamic nav

    Dtancredi
      Hi!

      First time poster, long-time troller. I've been working on a CMS system and having a little trouble creating a three level navigation, that's uses the functionality of the accordion component, but styled with dynamically loaded fonts.

      I'm using the "flexlibs" swc (and was playing with degrafa, but think it's a little much for what I'm trying to do). What I'm doing is:
      - pulling the three level navigation (1st level - brand, 2nd - campaign, 3rd - job),
      - a VBOX holds the entire nav, the first level is an accordion with:
      -- a header (that somehow draws the data (this is my first question) to put in a swc I created, in a Header.mxml component.); and a
      -- repeater that does the same thing for "campaign" (2nd level): vbox, vaccordion (header + repeater), that holds:
      -- a swc component, called "JobComp" (I've been playing swapping it with a flash-made swc but can't seem to figure out how to pass initialization variables in the constructor)

      I used "swc"'s for the nav components, because the fonts are "AGBuchBQ-Bold" and I thought it'd be easier this way.

      I guess my question(s) are:
      1. How do I pass a variable in the constructor of a swc Component?
      2. Am I doing this right? Or should I construct the navigation ALL in flash, export as a swc, and just pass in the xml to the flash component (which means I need to understand #1...)
      3. Is there a way to load / set font in the accordion / list components that are not the basic fonts? If I can style it all in the .css, that'd be really really helpful, I think, since it's 90% there.

      Thanks again, for any input,
      Dom
        • 1. Re: swc / accordion problem, trying to create a 3-level dynamic nav
          laurent_pinson
          IMO, you should code this in ActionScript. You create your VBox, Accordion in MXML and then use ActionScript to populate it.

          You can pass property to constructor only in ActionScript not MXML (and only if they accept it).

          Hopping, it helps you

          ps: imo², double point doesn't work to get a property
          • 2. Re: swc / accordion problem, trying to create a 3-level dynamic nav
            Dtancredi Level 1
            So just build the VBOX in mxml, and build the rest in actionscript, as a swc or in the script tag?

            Should I be creating the flex components in actionscript too or just try to build everything in AS?

            I got really close with the styling of the accordion component in flex, just the borders and the mouse_down state are showing.

            The data's loading properly, if that's what you mean by double point?
            • 3. Re: swc / accordion problem, trying to create a 3-level dynamic nav
              laurent_pinson Level 1
              My bad i didn't see that you want to create a swc.

              Well, as i said earlier, for me, the only way to pass parameter to a constructor (i suppose you mean like new Label("my title")) is using actionscript.
              What you can do if you want to create an MXML file is creating public parameters (or getters) in the script tag and use the [bindable]. As far as i understood Flex, properties in an MXML will have no action on your component if you don't use this tag.
              You can as well create a method that will apply these parameter after its creation, example :

              You create a MyComponent class which has different properties like displaySubComponent and maximumValue. In your class, you create a method called "applyParameters" which will do something to initialize it.
              Then you call use it like this:

              <c:MyComponent id="a_component" displaySubComponent=[ A, B, D] maximumValue=5 onCreationComplete={a_component.applyParameters()} />


              And yes, i thought "dataProvider="{repeatCampaign.currentItem..job }" was strange but it's good to know that we can do that ;)

              Hope, i was understandable ^^"

              • 4. Re: swc / accordion problem, trying to create a 3-level dynamic nav
                Dtancredi Level 1
                Thanks so much!

                I ended up generating the menu and saving the code for a rainy day, then pumping a lot of energy into getting the styles to work on the above code. The real roadblock was getting the fonts to load from the .css properly. But once I did that, and researched on the over and down states, it become much more of what the design asked for.

                This really helped too:
                http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html

                Thanks again! I really appreciate it,

                Dom