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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:42:58+00:00 2026-05-26T09:42:58+00:00

Okay, so first, I have searched for this everywhere but it seems like every

  • 0

Okay, so first, I have searched for this everywhere but it seems like every answer is either overcomplicated or simply does not work, and I know for sure there should be a more simple way of achieving what I need.

So, until today, I have always coded from within the timeline. But now I realise why I should code in separate class files. However, I still want to include snippets of code in the timeline for simplicity’s sake.

So in my Ship class I have this line of code:

    public var speed:int = 2 + Math.ceil(Math.random() * 4)

And in my timeline I have the code:

import Ship;
trace(Ship.speed)

I can’t get the trace to display the speed. The class file executes perfectly on its own but when I try to access its speed variable (as above in the timeline), I get this:

Scene 1, Layer ‘Actions’, Frame 1, Line 2 1119: Access of possibly undefined property speed through a reference with static type Class.

So a simple question, and apologies for it, but can anyone give me a simple way to trace the speed from the Ship.as class file?

Thanks 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-26T09:42:58+00:00Added an answer on May 26, 2026 at 9:42 am

    You need to create a Ship instance, like this:

    import Ship;
    var ship:Ship = new Ship();
    trace(ship.speed);
    

    OR

    You can declare speed as a static variable to access it without the need of an instance (but I think here it makes less sense):

    public static var speed:int = 2;//or whatever
    

    To learn more about static variables and methods in AS3, check this response: Actionscript 3: Can someone explain to me the concept of static variables and methods?

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

Sidebar

Related Questions

Okay at first I thought this would be pretty straightforward. But I can't think
Okay, so I have searched this site and found many tutorials on how to
Okay look first thanks for this place :) I would like to create a
Okay so heres what I have but whenever I do this, I am returned
Okay so I have two import pieces of code involved in this. This first
Okay. I have completed my first python program.It has around 1000 lines of code.
first, I can't stand Crystal! Okay, that's off my chest... Now, we have an
Okay this is my first WPF app and I am having a hard run
Okay this question is very simple: I have a facebook page, and a website.
Okay, I feel a bit foolish for having to ask this but I guess

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.