Simple XML to ActionScript 3 Menu

18Jun08

flash

This is actually my first attempt to make a menu XML customizable driven. I will probably release a new version soon.


This

Download the sample files here. The .fla file is included. Any comments on the code is appreciated. Feel free to use!!

Goto My new Blog and Download the newest Version … ( many thanx to celeiner for his contribution)

Advertisements


19 Responses to “Simple XML to ActionScript 3 Menu”

  1. 1 mike

    LOVE IT!

  2. 2 wonky

    Looks like it could be really good but it tells me there is an error with the location of the CallArg.as……
    I’ve tried changing its location and the Import location on the main fla but to no joy… 😦

    I’ve been try to learn how to make an animated XML AS3 menu in for weeks now and just cant do it… or can I find a good tutorial…

    how did you learn how to do this???

    thanks in advance

    V

  3. 3 worthposting

    in any flash file you need to specify the your class directory

    CTRL + SHIFT + F12 (Publish Settings)

    Tab Flash
    Settings Button
    Enter the Class Path with (+) sign something like
    “[directory where .fla is located]\com\utils”

    in my case was:
    I:\flash\mainmenu\com\utils

    this CallArg.as is actually a good class that overrides the addEventListener handler so that you can pass extra custom values.

    Good practice examples are all over the net…. Keep searching. If you need anything else I m here.. :p

  4. 4 HSCharles

    I have a flash site
    i’m looking for the script who of google ads on flash.
    how can i get it?

  5. 5 selleriee
  6. 6 Missvania

    Hi. I would like to get the file. But am unable to download it off rapid share. Is there any where else I can download that from?

    Or, can I trouble you to send me a copy of it?

    I need it urgently, I need to see how this is done and learn it. It would be a great help if I can get it.

    Thanks alot.

    Cheers,
    Vanessa

  7. 7 worthposting

    Missvania the link works ok (i checked it)… maybe you should check if you have a problem with rapidshare.

  8. 8 Missvania

    I think I do. I can never download from rapidshare Is there other options for me to download it?

    Thanks.

    Cheers,
    Vanessa

  9. 9 Dimitree

    Hi, this is a great menu very well constructed.
    Is there any way I can place the hand cursor on top of the text? I tried to add a movieclip and place the text inside with the addChild method and I get many troubles… (also buttonMode=true…etc)
    Any suggestions?

  10. 10 worthposting

    sorry if this give you any troubles but its really my first try.

    You may have to set buttonMode = true and useHandCursor = true. I can’t remember if the hand cursor is on by default.

  11. 11 Dimitree

    First of all thanks for the menu!
    – Well, I ;ve spend two days so far and still trying…
    The thing is that in order to make the hand cursor work the dynamic Text must be placed into a MovieClip etc…
    If I get a result I ll post the code.
    (In my sense it a menu MUST have a handcursor on top of each of its elements, for sake of usability πŸ˜‰ )

  12. 12 worthposting

    I ll be releasing a DHTML menu with quite same structure. If you look at the code you ll see it has many thing to learn from. Love CallArg override class …

  13. 13 celeiner

    here’s the trick for the hand cursor

    import flash.ui.Mouse

    function buttonModeTrue(event:Event):void
    {
    Mouse.cursor=”hand”
    event.target.setTextFormat(textFormatMainUp);
    }
    function buttonModeFalse(event:Event):void
    {
    Mouse.cursor=”arrow”
    event.target.setTextFormat(textFormatMain);
    }

    function buttonModeSubTrue(event:Event):void
    {
    Mouse.cursor=”hand”
    event.target.setTextFormat(textFormatSubUp);
    }
    function buttonModeSubFalse(event:Event):void
    {
    Mouse.cursor=”arrow”
    event.target.setTextFormat(textFormatSub);
    }

    • 14 worthposting

      Thanx ..
      I found another solution .. but it required to put the text fields in a container… (spite or mc )
      I ll try it ..
      Looks Promising !!! Thanx Again … I ll post the new code here …

  14. 15 davit

    Well done navigation..even if you say this is your first, it looks pro. congrats.
    will show you what you made possible when am done
    just one Question.
    would you know why the sub menus wont show up if you apply a background picture to the stage through a new layer right under your 3 layers? the main menu shows fine…i tried changing the font color and stuff but nothing worked for me so far. what you think guys?

  15. 16 worthposting

    At some point in the code you ll see
    setChildIndex(dynText,numChildren – 1);

    try putting the image “by code” and finally do this
    setChildIndex(youImage,numChildren – 1);

    Or if you dont really know how to do that …
    Make a Layer in the TimeLine Place your Layer at the end.
    (You could try doing this also Change
    setChildIndex(dynText,numChildren – 1);
    to
    setChildIndex(dynText,numChildren – 1); )

    • 17 davit

      i changed
      setChildIndex(dynText,numChildren – 1);
      to
      setChildIndex(bgpic,numChildren – 1);
      and
      i cant even see the main links anymore. just the gray box.
      when i crate a layer for the bg and put it under everything i just see the main links/blue gray bg…cant get behind the sub menus still

      • do not change the excisting
        setChildIndex(dynText,numChildren – 1);

        under the whole as3 code
        Add your code and do this
        setChildIndex(bgpic,numChildren – 1);
        or
        setChildIndex(bgpic,numChildren – 2);

        This AS3 has new a way of handling the depth of objects in the stage.
        Do some reading about this
        here http://as3.metah.ch/ in this article
        “Deepth of MovieClip with setChildIndex in AS3”

  16. Hello, and Thank you so much for this code!! i searched so long for something like this. Im trying to understand the full code to 100% but its really hard cause i startet a little bit 6 month ago.. before i only did html nd css – would it be easier learn before as3 something else? but i’ve only got so much inspiration for flash to be ready to learn so much. =)

    so could u or somebody help me explain this code:

    createMainText(xmlList[i].@title, xmlList[i].attribute(“link”) ,getChildByName(“mainLink”+(i-1).toString()).width + getChildByName(“mainLink”+(i-1).toString()).x + subLinkPadding, 8 , i );

    an the other thing is this callarg package…?

    is it like a switch. and i could use instead of:
    (MouseEvent.CLICK, CallArg.create(gotoSub, linkSub));

    this:

    (MouseEvent.CLICK, gotoSubLink)

    so sry for my english!!
    i would be so thankfully if someone could help me explain!

    Cheers,
    pablo from switzerland πŸ˜€


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: