简体   繁体   中英

Flash AS3: How to “hide” layers when not in use

I created a flash layout for a brochure software we're using and I'm running into a layering issue.

When someone clicks on one of the "+" buttons, it changes the image to the right and goes to a frame that plays a simple animation to bring up the "lightbox".

The issue I'm having is that the "+" buttons that are covered by a lightbox at some point won't function, even if those layers aren't active at that point in the timeline.

Is there a way to have the button layer be on top until clicked on? Once it's clicked, the movieclip layer should be on top.

I attached a sample of the layout here.

在此处输入图片说明

Hide layer without codes.

  1. Click layer
  2. On properties click fill > alpha , from 100 change it to zero (transparent)

By the way, the answer above gives you headache. The person asked for a simple solution, but you confused him.

您可以将这些图层的visible属性设置为false

If you are wanting throw certain objects on top during run time (not during editing), look into setChildIndex() to re-arrange which object is on top of the others in your swf.

    import flash.events.MouseEvent;

    // Listen for a click (you would want to add for each of your buttons, 
    // optionally an array or vector would be handy here)
    yourButtonName_mc.addEventListener(MouseEvent.CLICK, buttonClicked);

    // Whenever your button is clicked call this
    function buttonClicked(evt:MouseEvent)
    {
        // Throw the specific object on top of everything else
        // This assumes that thingToThrowOnTop_mc is a direct child of the stage
        setChildIndex(thingToThrowOnTop_mc, numChildren-1);
    }

You can also look into swapChildren() or the other variants as well.

Please keep in mind that layers only exist at run time for convenience in editing, when the swf is running they no longer exist; however, objects that were in layers are usually MovieClip instances or other DisplayObjects . In case you were not aware, adding an instance name to these objects will allow you to access them directly via ActionScript.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM