How to define an object in actionscript 3 using a custom class


Hi my problem is i have to be able to reference certain fields inside my Customer object.]

I am studying AS3 at the moment and being taught custom classes, but we are taught to use the toString method of returning a value i guess you could call it, what i need is to be able to call one field to identify the object i.e. name field from the object in the array, here's my code

package valueObjects { public class Person { //instance variables protected var name:String; protected var address:String; protected var phoneNo:String; public function Person(n:String,a:String,p:String) { name=n; address=a; phoneNo=p; } public function toString():String { //returns string return name+":"+address+":"+phoneNo; } }


some reason it will not put that whole block of code together like <a href="http://gyazo.com/b9c3e972968bf357eb797e2df95e5d38" rel="nofollow">THIS IS</a>

So now how do i define it not toString but in object form ??


I think what you are trying to do is access the name, address and phoneNo vars from a different class?

If so, you have to declare them as public vars instead of private vars.

public var name:String; //now this can be accessed from other classes: thisClassInstance.name

If you want to have them read-only from other classes, you have to use a getter method:

protected var name_:String; //local var name for full access; public function get name():String { return name_; //this can be access by doing thisClassInstance.name }


  • Flex is deserializing generic objects from Zend AMF instead of strictly typed objects
  • how can i handle images and change there function?
  • Unreachable code in eclipse
  • How to Mask certain fields in Protobuf
  • PHP can't decompress gzip data by Golang
  • How to create the new target in Xcode for app extension using CMake?
  • Can't get any output from the taglib
  • Add class element based on the name of the page
  • Using an enum contained in a Cloud Endpoint model on a Android client
  • Java Garbage collection, setting reference to null
  • rapply over a nested list in R
  • Implementation of RTTI using typeid
  • Powershell Hash Table to HTML
  • Randomizing -and remembering that randomisation- multiple choice questions in php
  • How do I retrieve the user information of a user authenticated with Apache's mod_ldap?
  • netsh acl setting (need alternative method - registry settings?)
  • how to set variables in a php include file?
  • How to specify input and output paths from cmd.exe for a PowerShell script?
  • ThreadStatic in asynchronous ASP.NET Web API
  • Recording logins for password protected directories
  • Retrieving value from sql ExecuteScalar()
  • How to extract text from Word files using C#?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Calling of Constructors in a Java
  • PHP: When would you need the self:: keyword?
  • KeystoneJS: Relationships in Admin UI not updating
  • WPF Applying a trigger on binding failure
  • Benchmarking RAM performance - UWP and C#
  • Hits per day in Google Big Query
  • Angular 2 constructor injection vs direct access
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • Change div Background jquery
  • How does Linux kernel interrupt the application?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • Checking variable from a different class in C#
  • Does armcc optimizes non-volatile variables with -O0?
  • Busy indicator not showing up in wpf window [duplicate]
  • Conditional In-Line CSS for IE and Others?
  • Why do underscore prefixed variables exist?