ActionScript 3.0 Language and Components Reference | All Packages | All Classes | Language Elements | Index | Appendixes | Conventions | Frames No Frames |
Sample

Package | flash.sampler
Class | public class Sample
Inheritance | Sample Object
Subclasses | DeleteObjectSample, NewObjectSample

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9.0.115.0

The Sample class creates objects that hold memory analysis information over distinct durations. For Flash Player debugger version only.

View the examples

See also

flash.sampler.getSamples()

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | prototype : Object [static] A reference to the prototype object of a class or function object. | Object

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Public Constants

| Constant | Defined By
--- | --- | ---
|  | stack : Array Contains information about the methods executed by Flash Player over a specified period of time. | Sample
|  | time : Number The microseconds that define the duration of the Sample instance. | Sample

Constant Detail

stack | Constant

`public const stack:Array`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9.0.115.0

Contains information about the methods executed by Flash Player over a specified period of time. The format for the stack trace is similiar to the content shown in the exception dialog box of the Flash Player debugger version. For Flash Player debugger version only.

time | Constant |

`public const time:Number`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 9.0.115.0

The microseconds that define the duration of the Sample instance. For Flash Player debugger version only.

Examples How to use examples
SampleTypesExample.as
The following example uses the `stack` and `time` properties of a Sample object `s` to collect memory samples. The samples contain NewObjectSample objects (the `newSamples` array), DeleteObjectSample objects (the `delSamples` array), and CPU memory sample objects (the `cpuSamples` array). To use the memory profiler, you need to have Flash Player debugger version 9.0.115.0 or later installed.

    package
    {
        import flash.sampler.*
        import flash.system.*
        import flash.utils.*
        import flash.display.Sprite
        public class sampleTypes extends Sprite
        {
          var b:Boolean = true
            public function sampleTypes() {
                flash.sampler.startSampling();
                for(var i:int=0;i<10000;i++)
                  new Object();

                var cpuSamples:Array=[];
                var newSamples:Array=[];
                var delSamples:Array=[];
                var ids:Array=[]

                var lastTime:Number=0;
                for each(var s:Sample in getSamples()) {

                  assert(s.time > 0); // positive
                  assert(Math.floor(s.time) == s.time, s.time); // integral
                  assert(s.time >= lastTime, s.time + ":" + lastTime); // ascending
                  assert(s.stack == null || s.stack is Array)
                  if(s.stack) {
                    assert(s.stack[0] is StackFrame);
                    assert(s.stack[0].name is String);
                }

                  if(s is NewObjectSample) {
                    var nos = NewObjectSample(s);
                    assert(s.id > 0, s.id);
                    assert(s.type is Class, getQualifiedClassName(s.type));
                    newSamples.push(s);
                    ids[s.id] = "got one";
                  } else if(s is DeleteObjectSample) {
                    var dos = DeleteObjectSample(s);
                    delSamples.push(s);
                    assert(ids[dos.id] == "got one");
                  } else if(s is Sample)
                    cpuSamples.push(s);
                  else {
                    assert(false);
                  }
                  lastTime = s.time;
                }

                trace(b)
                trace(newSamples.length > 0)
                trace(cpuSamples.length > 0)
                trace(delSamples.length > 0)

            }

            private function assert(e:Boolean, mess:String=null):void {
              b = e && b;
              if(true && !e) {
                if(mess) trace(mess);
                trace(new Error().getStackTrace());
              }
            }
        }
    }

Submit Feedback on LiveDocs
© 2004-2008 Adobe Systems Incorporated. All rights reserved.
Tue May 20 2008, 04:02 AM -07:00