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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:16:55+00:00 2026-05-18T12:16:55+00:00

In my main Actionscript file i have a instance of a body class that

  • 0

In my main Actionscript file i have a instance of a body class that moves the person body arms legs etc. and a gun class which has methods and properties to do with the person gun.

Right now i have a function in the Main class which is called move gun and looks like this and is called everyframe to move the gun to the bodys arm. I was hoping to move this function to the guns class so i could call it like gun.moveGun(); but the body dosent exist inside the gun variable. so i wonder if i could call the body.getArm(); function from inside the gun. I know i could call the function and pass the bodys arm location to it from the main file. But don’t know if this is the best way to do it.

private function moveGun():void
    {
        gun.x = body.getArm('left').x;
        gun.y = body.getArm('left').y;
    }

It seems like keeping the gun related functions inside the gun class is the best way to organise everything but i dont know how to do this.

Also depending what button someone clicks at the start the person will either have a basketBall or gun in there hand. Ive added the swf online at Here so you can see how it works. i just wanna change how its organised because the main file is very full and though i should learn how to organise things better. There are lots of other part of the program that would be organised better if i knew how to get the object to interact or what is the best way to do it. Starting to think passing the x,y coordinates to the moveGun function inside the gun Class is the best way. If so just tell me please and ill do that.

  • 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-18T12:16:56+00:00Added an answer on May 18, 2026 at 12:16 pm

    From the code you posted, I think you need to move the gun with every frame to stick to the player’s arm.

    The answer you’re looking for is Composition, since every person gets one and only one gun, I think you better put a reference (variable) in the person class for its gun.

    and here is your player (person) class:

    class Person
    {
        private var m_gun:Gun;
    
        public function Person()
        {
            this.m_gun = new Gun();
        }
    
        // a function which is called each frame
        private function updateFrame()
        {
            // Here you can provide your own logic in Gun class
            this.m_gun.doSomething();
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a swf file sample.swf which has its actionscript class in Main.as. This
How would you compile actionscript code whose main class is inside a package using
My main window has spawned a child window that's positioned on top to look
The main web application of my company is crying out for a nifty set
My main JavaScript framework is jQuery , so I would like my unit test
function main() { Hello(); } function Hello() { // How do you find out
The main user-case is: Create the 2D floor plan See the 3D view of
Why main must be declared as if it has external linkage? Why it should
My main browsers (FF and Chrome) are both configured for a 12 pixel font.
The main jQuery method takes a second optional argument to provide context for 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.