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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:32:15+00:00 2026-05-28T05:32:15+00:00

Ok so i have a character on the screen and when it moves the

  • 0

Ok so i have a character on the screen and when it moves the camera follows(thanks to manifest222 on youtube) i have a wall where the player cant go through. I also have boxes adding to the stage but i want it so that the box adds to onto another object hers the code.

package {
    import flash.display.Sprite;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.display.Stage;

public class Main extends MovieClip {
    // player

    public var characterEndMC:MovieClip = new charEndMC();
    public var arrayOfBarrier:Array = new Array();

    //box
    private var boxAmount:Number=0;
    private var boxLimit:Number=20;
    private var _root:Object;
    //$txt
    public var money:int=0;
    public var gold:int=0;
    public var my_scrollbar:MakeScrollBar;

    //$$
    public var testnumber:Number=1;
    //enemy1
    private var e01Amount:Number=0;
    private var e01Limit:Number=2;



    public function Main() {


        $box.click$.move$.buttonMode=true;
        $box.click$.clickmini$.buttonMode=true;
        backgroundpic.visible = false;



        character_mc["charAngle"]=0;
        character_mc["moveX"]=0;
        character_mc["moveY"]=0;
        character_mc["walkSpeed"]=5;
        stage.addEventListener(MouseEvent.CLICK, charMove);


        //box add listener
        addEventListener(Event.ENTER_FRAME, eFrame);

        //moneybox
        $box.click$.move$.addEventListener(MouseEvent.MOUSE_DOWN, startmoving$);
        $box.click$.move$.addEventListener(MouseEvent.MOUSE_UP, stopmoving$);
        $box.click$.clickmini$.addEventListener(MouseEvent.CLICK, c$mini);

        my_scrollbar=new MakeScrollBar(scroll_mc,scroll_text);




    }



    public function charLoop(event:Event) {
        if (character_mc.hitTestPoint(character_mc["charEnd"].x,character_mc["charEnd"].y,true)) {


            character_mc["moveX"]=0;
            character_mc["moveY"]=0;
            this.removeChild(character_mc["charEnd"]);
            character_mc.removeEventListener(Event.ENTER_FRAME, charLoop);



        }

        for (var j:int = 0; j < arrayOfBarrier.length; j++) {
            if (character_mc.hitTestObject(arrayOfBarrier[j])) {
                character_mc.x-=character_mc["moveX"];
                character_mc.y-=character_mc["moveY"];
                character_mc["moveX"]=0;
                character_mc["moveY"]=0;
                this.removeChild(character_mc["charEnd"]);
                character_mc.removeEventListener(Event.ENTER_FRAME, charLoop);

            }
        }

        for (var i:int = 0; i < this.numChildren; i++) {
            this.getChildAt(i).x-=character_mc["moveX"];
            this.getChildAt(i).y-=character_mc["moveY"];

        }

        character_mc.x+=character_mc["moveX"]+.05;
        character_mc.y+=character_mc["moveY"]+.05;


    }

    public function lookAtMouse() {
        var characterMC:MovieClip=character_mc;
        characterMC["charAngle"] = Math.atan2(this.mouseY - characterMC.y, this.mouseX - characterMC.x) / (Math.PI / 180);

        characterMC.rotation=characterMC["charAngle"];
    }
    public function charMove(event:MouseEvent) {
        lookAtMouse();
        this.addChild(characterEndMC);
        characterEndMC.x=this.mouseX;
        characterEndMC.y=this.mouseY;

        character_mc["charEnd"]=characterEndMC;
                    character_mc["charEnd"].visible = false;


        character_mc["moveX"]=Math.cos(character_mc["charAngle"]*Math.PI/180)*character_mc["walkSpeed"];
        character_mc["moveY"]=Math.sin(character_mc["charAngle"]*Math.PI/180)*character_mc["walkSpeed"];



        character_mc.addEventListener(Event.ENTER_FRAME, charLoop);


    }




    //boxadding
    private function eFrame(event:Event):void {
        if (boxAmount<boxLimit) {
            boxAmount++;

            var _box:Box=new Box  ;
            _box.addEventListener(MouseEvent.CLICK,boxclick);
            _box.buttonMode=true;
            _box.y=Math.random()* backgroundpic.height;

            _box.x=Math.random()* backgroundpic.width;

            addChild(_box);

        }
        if (e01Amount<e01Limit) {
            e01Amount++;

            var Enemy1: enemy01=new enemy01  ;
            Enemy1.addEventListener(MouseEvent.CLICK, en01click);
            Enemy1.buttonMode=true;
            Enemy1.y=Math.random()*stage.stageHeight;

            Enemy1.x=Math.random()*stage.stageWidth;

            addChild(Enemy1);

        }

    }

    public function boxclick(event:MouseEvent):void {

        var _box:Box=event.currentTarget as Box;
        logtxt.appendText("You collected " + testnumber +  " boxes" + "\n" );
        character_mc["moveX"] = _box.y + 40 + (character_mc.height / 2);
        character_mc["moveY"]=_box.x;


        logtxt.scrollV=logtxt.maxScrollV;
        var randVal$:Number=Math.random();
        if (randVal$>=0.49) {
            money+=100;
        } else if (randVal$ <= 0.50 && randVal$ >= 0.15) {
            money+=200;
        } else if (randVal$ <= 0.14 && randVal$ >= 0.02) {
            gold+=10;
        } else if (randVal$ == 0.01) {
            money+=200;
            gold+=20;
        }


        testnumber++;



        boxAmount--;


        $box.box$in.box$insins.Moneytxt.text=String(money);
        $box.box$in.box$insins.Goldtxt.text=String(gold);
        removeChild(_box);

    }

    private function startmoving$(event:MouseEvent):void {
        $box.startDrag();
    }
    private function stopmoving$(event:MouseEvent):void {
        $box.stopDrag();
    }
    private function c$mini(event:MouseEvent):void {
        $box.click$.move$.visible=false;
        $box.box$in.visible=false;

        $box.y=200;
        $box.x=100;
        $box.click$.clickmini$.addEventListener(MouseEvent.CLICK, reclickbox$);
        $box.click$.clickmini$.removeEventListener(MouseEvent.CLICK, c$mini);


    }
    private function reclickbox$(event:MouseEvent):void {
        $box.click$.clickmini$.addEventListener(MouseEvent.CLICK, c$mini);
        $box.click$.clickmini$.removeEventListener(MouseEvent.CLICK, reclickbox$);
        $box.y=70;
        $box.x=250;
        $box.click$.move$.visible=true;
        $box.box$in.visible=true;
    }

    public function scroll_text( n:Number ) {

        logtxt.scrollV = Math.round( ( logtxt.maxScrollV - 1 ) * n ) + 1;
    }

    public function en01click (event:MouseEvent){

    }

}
}
  • 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-28T05:32:16+00:00Added an answer on May 28, 2026 at 5:32 am

    That’s:

    var _box:Box = new Box();    
    receivingDisplayObjectInstanceName.addChild(_box);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string I'm writing to the screen one character at a time.
I have a character in an iPod Touch game I am making that moves
An Example of the problem Randomly i have a character on screen. He starts
Currently I have a cartoon character that takes up almost the full screen of
I have a character array and I'm trying to figure out if it matches
Is a string actually a character array (is-a), or does it have a character
I have some 256-character strings of hexadecimal characters which represent a sequence of bit
They're both resizable arrays, and std::basic_string doesn't have any specifically character-related functions like upper().
I have a single hexadecimal character, say char c = 'A'; What's the proper
I have email addresses encoded with HTML character entities. Is there anything in .NET

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.