A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: Layer above actionScript

  1. #1
    Member
    Join Date
    Oct 2003
    Location
    Norwich
    Posts
    87

    Question Layer above actionScript

    How do you place a layer above actionscript? In my experience any graphics from a movie clip or button etc called by actionscript are visible above the highest layer in the timeline. What am I doing wrong?

    Thankyouuuuuu

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    addChild adds to the top of whatever container is being added to. The default behavior from frame code is therefor to add the new instances at the top of the root. But you could create a container at another layer and add to that instead. Or you could use addChildAt to add to a lower level without an organizing container.

  3. #3
    Member
    Join Date
    Oct 2003
    Location
    Norwich
    Posts
    87
    sorry I'm a bit of a beginner. What exactly is a container? do you know of any tutorials?

    thanks again

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    By container, I meant any DisplayObjectContainer. That is, any Sprite or MovieClip, usually with no appearance of its own. If you had such a clip on stage named "container", you could add a new child to it by calling its addChild method.
    Code:
    container.addChild(thingy);

  5. #5
    Member
    Join Date
    Oct 2003
    Location
    Norwich
    Posts
    87

    Question DisplayObjectContainer

    So does all the content I have at present have to go into a DisplayObjectContainer and then the graphic I want to appear above this needs to be in addChild?

  6. #6
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You don't have to re-arrange all your current stuff, you just need to understand the display list, which is actually a tree.

    Each DisplayObject on the display list is a child of another DisplayObjectContainer, all the way up to the stage. Each DisplayObjectContainer (MovieClip or Sprite) can have multiple children. Direct siblings are shown from bottom to top in their child order. If A is on top of B, all children of A will be on top of B and all children of B.

    So if you want to add children dynamically at a particular relative level, create an empty movieclip at that level, and add your children to that.

  7. #7
    Member
    Join Date
    Oct 2003
    Location
    Norwich
    Posts
    87
    I'm afraid I'm still confused. I'm trying to get the clouds and rain words to disappear behind the grey block and the white frame. This is the file so far:

    http://www.financial-angels.net/images/banner.fla

    Thanks for your time, much appreciated!

  8. #8
    Junior Member
    Join Date
    Mar 2010
    Posts
    4
    Hi I was just browsing around here because I am lost as well but I really like how you set up your site and that dayng debt was following eme on your site and was irritating...lol good job and very imaginative.

  9. #9
    Junior Member
    Join Date
    Mar 2010
    Posts
    4
    container.addChild(thingy);

    what would (thingy) be?

    sorry I am very new at this

  10. #10
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    thingy in that example code is any DisplayObject which you would like to be a child of the container.

  11. #11
    Junior Member
    Join Date
    Mar 2010
    Posts
    13
    I had a similar problem recently and this will help me as well. I can't wait to try it. What I think 5Tons is saying Skippers, is to create a new movieclip in AS.

    var mc2HoldButtons:Movieclip = new MovieClip();
    addChild(mc2HoldButtons);

    am I close 5Tons?
    how do you tell it to add the buttons?

    OR maybe you can just use a MC already created and use addChild(the name of one of the buttons) or addChildAt.
    Last edited by christylove; 03-21-2010 at 10:48 AM. Reason: trying to figure this out...lol

  12. #12
    Member
    Join Date
    Oct 2003
    Location
    Norwich
    Posts
    87
    If I was to have an invisible button above everything I wouldn't want the cursor to change to a hand unless it was over a real button

  13. #13
    Junior Member
    Join Date
    Nov 2008
    Posts
    23
    As 5TonsOfFlax is trying to say you need to use a DisplayObjectContainer.

    I will try and give you an example.

    Create two layers:
    1st layer (Top layer) Holds all your text you used in the GUI.

    2nd layer (Bottom) holds a MovieClip that you will use as a container.

    Open the actions and use addChild() to add a button or movieclip to the 2nd layers MovieClip and you will see that the text is over the movieclip, so the movieclip and children are not overlapping the text.

    Hopefully you can understand that :P.

    -Alex

  14. #14
    Member
    Join Date
    Oct 2003
    Location
    Norwich
    Posts
    87
    I'm thinking what I need is an animation that disappears once the mouse hovers the stage, which then activates the words raining from the clouds (these will be hidden originally)
    Then once the mouse moves close to the click for help button anther animation activates.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center