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 8352231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:54:24+00:00 2026-06-09T08:54:24+00:00

this is my code. package core { import flash.display.MovieClip; import flash.events.MouseEvent; import flash.geom.Point; public

  • 0

this is my code.

package core
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.geom.Point;

    public class earth extends MovieClip
    {
        protected var position:Point = new Point(x, y);
        public function earth()
        {
            stage.earthText_mc.visible = false; //HAVING PROBLEM WITH THIS LINE
            buttonMode = true;
            addEventListener(MouseEvent.MOUSE_DOWN, down);
        }
        protected function down(event:MouseEvent):void
        {
            parent.addChild(this);
            startDrag();
            addEventListener(MouseEvent.MOUSE_UP, up);
        }
        protected function up(event:MouseEvent):void
        {
            stopDrag();
            if(dropTarget)
            {
                if(dropTarget.parent.name == "mercury_drop")
                {
                    x = position.x = 279.95;
                    y = position.y = 267.15;
                }
                else if(dropTarget.parent.name == "venus_drop")
                {
                    x = position.x = 342.55;
                    y = position.y = 267.15;
                }
                else if(dropTarget.parent.name == "earth_drop")
                {
                    x = position.x = 418.2;
                    y = position.y = 267.15;
                }
                else if(dropTarget.parent.name == "mars_drop")
                {
                    x = position.x = 497.6;
                    y = position.y = 267.15;
                }
                else if(dropTarget.parent.name == "jupiter_drop")
                {
                    x = position.x = 613.65;
                    y = position.y = 267.15;
                }
                else if(dropTarget.parent.name == "saturn_drop")
                {
                    x = position.x = 738.4;
                    y = position.y = 267.15;
                }
                else if(dropTarget.parent.name == "uranus_drop")
                {
                    x = position.x = 844.8;
                    y = position.y = 267.15;
                }
                else if(dropTarget.parent.name == "neptune_drop")
                {
                    x = position.x = 939.65;
                    y = position.y = 267.15;
                }
                else
                {
                    x = position.x = 517.2;
                    y = position.y = 35.5;
                }
            }
        }
    }
}

All I want is to make the text “EARTH” invisible when I open run the flash, using only the code.. But I can’t connect to the movie clip “earthText_mc”. This script is connected at the “earth_mc” only.. I don’t know how to call the other movie clips and make them visible or invisible as I want them to..

  • 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-09T08:54:25+00:00Added an answer on June 9, 2026 at 8:54 am

    Have solved the problem.

    shortly, the solving code is below.

    var earth_text:MovieClip = this.parent.getChildByName("earth_text") as MovieClip;
    earth_text.visible = false;
    

    However, the this problem without knowing fully the as3.0 DisplayObject inheritance structure is a difficult problem to solve.
    First, a thorough understanding of the figure below should be.

    enter image description here

    this.parent is Stage.

    this.parent.getChildByName("earth_text") is DisplayObject.
    (take a closer look at the documentation for getChildByNames method please.)

    but type casting MovieClip. As you will see a document, this method is the actual return value of the DisplayObject. So you should be type casting.

    (if DisplayObject must be added to the stage. the code below do your work better.)

    public function earth()
    {
        if(!stage)
           addEventListener(Event.ADDED_TO_STAGE, init);
        else
           init();
    }
    private function init(e:Event=null):void
    {           
        removeEventListener(Event.ADDED_TO_STAGE, init);
    
        var earth_text:MovieClip = this.parent.getChildByName("earth_text") as MovieClip;
    
        earth_text.visible = false;
        buttonMode = true;
        addEventListener(MouseEvent.MOUSE_DOWN, down);
    }
    

    however, your all instance MovieClip in Stage. child index is very important. All DisplayObject, because they are conducted in the following order.

    Stage Load -> Your instance of MovieClip are added sequentially in the order index.
    

    So the following code was written and checked the console window.

    Earth.as

    var _parent:MovieClip = this.parent as MovieClip;
    for(var i:int = 0; i<_parent.numChildren; i++)
    {
        trace("index: " + i + " object: " + _parent.getChildAt(i));
    }
    

    Your original file is an index of the earth instance was 1. So if you run the above code does not find the object. the reason is check the below console, ‘ll Be able to understand.
    instance of Earth object is added, but the remaining objects are not loaded yet. So you must to rearrange the order of the object. Look at the bottom of the console of the modified file.

    Original Files.

    index: 0 object: [object Shape]
    index: 1 object: [object earth]
    index: 2 object: null
    index: 3 object: null
    index: 4 object: null
    index: 5 object: null
    index: 6 object: null
    index: 7 object: null
    index: 8 object: null
    index: 9 object: null
    index: 10 object: null
    index: 11 object: null
    index: 12 object: null
    index: 13 object: null
    index: 14 object: null
    index: 15 object: null
    index: 16 object: null
    index: 17 object: null
    

    how to rearrange instance of MovieClip object?

    1. click instance of earth object in stage.
    2. crtl+x
    3. crtl+shift+v(Paste the in its same place)

    p.s: Likewise the remaining objects should have a higher index than earth_text instance.
    (In the console, index 16 is a earth_text instance.)

    The modified file.

    index: 0 object: [object Shape]
    index: 1 object: [object MovieClip]
    index: 2 object: [object MovieClip]
    index: 3 object: [object MovieClip]
    index: 4 object: [object MovieClip]
    index: 5 object: [object MovieClip]
    index: 6 object: [object MovieClip]
    index: 7 object: [object MovieClip]
    index: 8 object: [object MovieClip]
    index: 9 object: [object venus]
    index: 10 object: [object mercury]
    index: 11 object: [object jupiter]
    index: 12 object: [object mars]
    index: 13 object: [object uranus]
    index: 14 object: [object saturn]
    index: 15 object: [object neptune]
    index: 16 object: [object MovieClip]
    index: 17 object: [object earth]
    

    instance DisplayObject must always be careful when using. are added in ascending order of index at parent.

    Please comment if you still do not understand. I’ll be glad to help. Good Luck

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

Sidebar

Related Questions

Consider this code: package Prova; import java.util.ArrayList; public class Prova { private ArrayList<String> people;
This piece of code is from Adobe docs : package { import flash.display.Loader; import
I've got the following simple code: package main; import java.util.concurrent.*; public class Main {
What is wrong with this source code? 1 package Core; 2 3 import java.sql.*;
I have this code: package com.powergroupbd.timer; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.CountDownTimer;
This is my code: package hello.project; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.opengles.GL10; import android.content.Context; import android.opengl.GLSurfaceView.Renderer;
This is my MyTasteActivity code: package MyTaste; import android.app.Activity; import android.content.Context; import android.os.Bundle; import
I'm testing this Go code on my VirtualBoxed Ubuntu 11.4 package main import (fmt;time;big)
Here's my code: package com.eggproject_hu.WPECommerceAdminSales.client; import java.lang.Boolean; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.Window; public class AblakVillogo
I didn't understand ..why I am facing this error.. Here is my code: package

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.