Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7573641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:14:01+00:00 2026-05-30T16:14:01+00:00

I have placed two custom components in the flex 4 application <preload:PreLoader horizontalCenter=0 verticalCenter=0

  • 0

I have placed two custom components in the flex 4 application

<preload:PreLoader horizontalCenter="0" verticalCenter="0" fontWeight="bold" fontSize="50" id="preLoader"/>
<util:Debug  top ="0" right="0" id="debug"/>

As per the order components added in the MXML, Debug will stay on top.

My intention is to always keep the Debug component on the top

the PreLoader component has all the logic to initializing the application including instantiation of some of the classes which intern has logic to add some other elements to the application (like below)

   FlexGlobals.topLevelApplication,addElement(someotherflexcomp);

Now, every time I add an element the normal behavior of flex/AS is that newly added element will stay on top of displaylist.

So I have written an function in the main app which needs to be called when ever a component/element is added to the main app.

       public function bringDebuggerFront():void{

            if (numElements > 2){

                swapElementsAt(numElements - 1,numElements - 2);
            }
        }

The idea here is straight forward, swap the display position of the last Nth(last element) element with the N-1 element which will be Debug component if called every time an element is added.

So, I need to add an extra line to reposition the debugger widow like this

    FlexGlobals.topLevelApplication,addElement(someotherflexcomp);
    FlexGlobals.topLevelApplication.bringDebuggerFront();

Not a big problem for now because, currently I am adding only three components in the run time, but I might add more in future and more over, I will have to work more (comment or remove that code scattered in multiple places) to disable this feature which is meant only for the debugging.

To avoid this, I attached add event listener which is suppose to be called when ever I add an element to the application but it seems like this is being called only for the two components which I have added in the mxml but not called when an element is added to the application using addElement() method

Here is the complete code of my main app

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:util="util.*" xmlns:preload="preload.*"
               add="bringDebuggerFront()">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <preload:PreLoader horizontalCenter="0" verticalCenter="0" fontWeight="bold" fontSize="50" id="preLoader"/>
    <util:Debug  top ="0" right="0" id="debug"/>
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

            public function bringDebuggerFront():void{

                if (numElements > 2){

                    swapElementsAt(numElements - 1,numElements - 2);
                }
            }
        ]]>
    </fx:Script>
</s:Application>

I even tried with added event also but I think thats the not correct one as its triggerning so many times which I am assuming is called for every internal displayobjects is added and also is giving errors which I did not digged into details

Thanks for the help in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:14:02+00:00Added an answer on May 30, 2026 at 4:14 pm

    If you are using Flex 4, you can achieve this with the depth property of the components

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two HTML tables which would ideally be placed side by side on
I have an array filled with instances of a custom class which contains two
if I have two custom implementation of IAuthorizationFilter, and both of them applied to
I have two ad options in my theme, Adsense and Custom. If the user
I have two custom validators that are in the same validation group. This validation
I do have two problems regarding custom controls: I created a custom UserControl public
I have two databases at two different places, both databases are same with table
I have two threads, a producer thread that places objects into a generic List
I have two text files, I want to place a text in the middle
I want to place a table on my page. I have two tables in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.