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

  • Home
  • SEARCH
  • 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 8818191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:03:03+00:00 2026-06-14T05:03:03+00:00

Hello to all I have 2 movieclips on stage with instance names: green &

  • 0

Hello to all
I have 2 movieclips on stage with instance names: green & orange.
I am using this code to timeline frame 1 to bring forward each item is clicked:

MovieClip.prototype.bringForward = function():void{
    var currentDepth = this.parent.getChildIndex(this);
    if(currentDepth<this.parent.numChildren-1){
        this.parent.setChildIndex(this, currentDepth+1); 
    }
}


green.addEventListener(MouseEvent.MOUSE_UP, clicked);
orange.addEventListener(MouseEvent.MOUSE_UP, clicked);

function clicked(e:MouseEvent){
    e.target.bringForward();
}

Can anybody tell me how to load this from an external .as file in this:

package  {


    public class Main {



        public function Main() {

        }



    }

}

I tried a lot of times but i didn’t had any luck.

I tried this:

package  {

    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.accessibility.AccessibilityProperties;
    import flash.display.Bitmap;
    import flash.display.DisplayObject;
    import flash.display.DisplayObjectContainer;
    import flash.display.MovieClip;
    import flash.display.Stage;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.KeyboardEvent;

    public class Main {




        public function Main() {


            addListeners();




        }



MovieClip.prototype.bringForward = private final function():void{
    var currentDepth = this.parent.getChildIndex(this);
    if(currentDepth<this.parent.numChildren-1){
        this.parent.setChildIndex(this, currentDepth+1); 
    }
}




        private final function addListeners():void
        {

            green.addEventListener(MouseEvent.MOUSE_UP, clicked);
            orange.addEventListener(MouseEvent.MOUSE_UP, clicked);

        }





    private final function clicked(e:MouseEvent)
    {
    e.target.bringForward();
    }





    }

}
  • 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-06-14T05:03:05+00:00Added an answer on June 14, 2026 at 5:03 am

    Don’t use the prototype thing. Make a function on the class like this:

    private function bringForward(clip:DisplayObject):void{
        var currentDepth:int = getChildIndex(clip);
        ... rest of your swapping logic
    }
    
    private function clicked(event:MouseEvent){
        bringForward(event.target as DisplayObject);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello all i am using this code to show flip animation...... i have a
Problem Hello all! I have this code which takes my jpg image loops through
Hello I currently have this code checking if a cookie exists, it works all
hello all this seems to be my problem I have a table in mysql
Hello all I have this problem that I can't seem to fix. I've been
Hello all this is my first post here i have been working in an
Hello All I am using infragsitics tree view control.I have one stored procedure that
hello all its my first application using Zend Framework i have followed tutorial it
hello all i have code from open source project that im integrating into my
Hello all i have the code below which produces four wheels each with the

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.