

With AS3, in order to duplicate the properties of a Display object instance to other instances, the “GraphicsCopy” class provides for an easier approach. It substitutes the graphics properties of an instance to other instance.
Public function GraphicsCopy (graphics:Graphics = null) // constructor
The Graphics instance in the parameter list that receives all drawing calls through drawing API (e.g. graphical property like color, line style) and returns it to the GraphicsCopy class instance thereby coping the stuff from one object to other instance through use of Copy method. The essentially creates a GraphicsCopy class instance and initializes its graphic properties in constructor of the class (displayobject instance) whose object has to be duplicated. Then use copy method of GraphicsCopy object to copy the values to new instance.
package {
import flash.display.Shape;
import com.examplee.display.GraphicsCopy; class circle extends Shape
{
public function get graphicsCopy():GraphicsCopy {
return gc1;
}
// constructor
function circle(){
private var gc1 = new GraphicsCopy(graphics);
}
}
var circle 1: circle = new circle ();
var circle 2: circle = new circle ();
circle1.drawCircle(100, 120, 50);
this.addChild(circle1); // add to display list
circle2.graphicsCopy.copy(circle1.graphicsCopy); //call copy method of graphicscopy class
}
If you would like to make a comment, please fill out the form below.
| Cox Bundle specials ||| Verizon Offers ||| Promotional Comcast cable offers |
Recent Comments