Hello everyone, This is my first post here. I have been trying to learn Action Script 3.0 for a while, and I keep seeing this forum show up, so I decided to join.
I need a little help with something if anyone has the time, It’s a problem regarding how to load movie clips from the library. I’ll give you a run down of the situation…
I have a new Action Script 3 FLA file, inside of this file I have a movie clip in the library called GridBox. The movie GridBox is linked to a class file, In the class file I have a package with a couple of lines of code that draw a box made of lines. This, so far, works perfectly.
In the FLA file, I have yet another movie clip, called MainGrid, this movie clip is linked to yet another class, this class loads one instance of the movie clip GridBox inside of the MainGrid movie clip. This also works perfectly.
Here is all my code so far:
GridBox class:
//Draws One Single Grid Box Using The Registration Point As The Center
package {
import flash.display.MovieClip;
import flash.display.Shape;
public class GridBox extends MovieClip {
var GridLine:Shape = new Shape();
public function GridBox() {
GridLine.graphics.lineStyle(1, 0x000000, 1);
GridLine.graphics.moveTo(-40, 0); //(x, y)
GridLine.graphics.lineTo(0, -20); //(x, y)
GridLine.graphics.lineTo(40, 0); //(x, y)
GridLine.graphics.lineTo(0, 20); //(x, y)
GridLine.graphics.lineTo(-40, 0); //(x, y)
addChild(GridLine);
}
}
}
MainGrid Class:
//Loads Movie To Stage
package
{
import flash.display.MovieClip;
public class MainGrid extends MovieClip
{
private var myMovieClip:MovieClip;
public function MainGrid():void
{
myMovieClip = new GridBox();
myMovieClip.x = 0;
myMovieClip.y = 0;
addChild(myMovieClip);
}
}
}
My question is, How can I alter the MainGrid class, so that it loads multiple instances of the movie GridBox at multiple different locations?
Would I use an array some how? would I use multiple addChild commands? I’m lost as what to do next.
Thanks.