To work in ActionScript 3 with an element added in the Flash Stage we use its instance name (the name written in the Properties panel, in the box whith "<Instance Name>").
In AS3 code you can also use objects stored in the Library panel (images, symbols), without adding their instance on the Stage. This is more advantageous because multiple instances of the same object from the Library can be added dinamically and interatively in the Flash presentation, using ActionScript.
To be able to use an element from Library in AS3, it must be stored in a special class, then, this class can be accessed in your code to create and use new instances.
To store the objects from Library in a class, you must enable the option "Export for ActionScript", which is found in the "Advanced" section, in the window which is opened by right-clicking on the object in the Library panel, and choose the Properties option (see in the image below).
// Defines a function that creates an instance of the Square class // with parameters for 'x' and 'y' distance, and rotation function addSquare(dist_x:Number, dist_y:Number, rot_z:Number):void { // Creates instance of Square class var ins_square:Square = new Square(); // Sets the distances 'x', 'y', and rotation ins_square.x = dist_x; ins_square.y = dist_y; ins_square.rotationZ = rot_z; addChild(ins_square); // Add the instance in the presentation } // call this function 3 times addSquare(38, 38, 0); addSquare(130, 130, -19); addSquare(250, 220, -45);- This code creates and adds in the Flash presentation three instances of the object Square, each with different values for the distances 'x', 'y' and for rotation.
The Class associated to an element from Library can be edited. You can add instructions and methods that will be applied to the instances created with that class.
Right-click on the object in the Library panel, and choose Edit Class.
Add the code you want, then save the file with this class in the same folder as the FLA document (the name of the file must be the same as the name of the class).
<ul> <li>http://coursesweb.net/html/</li> <li>http://coursesweb.net/css/</li> </ul>
.some_class { display: list-item; }
var obj = { "courses": ["php", "javascript", "ajax"] }; var jsonstr = JSON.stringify(obj); alert(jsonstr); // {"courses":["php","javascript","ajax"]}
$strhtml = '<body><div id="dv1">CoursesWeb.net</div></body>'; $dochtml = new DOMDocument(); $dochtml->loadHTML($strhtml); $elm = $dochtml->getElementById("dv1"); echo $elm->nodeValue; // CoursesWeb.net