AS3 Root Function issue
Hi All,
I am having an issue with AS3, which I cannot work out. Apologies if this is something very simple.
Basically, I have a pool of animations in the library. "testMc1", "testMc2", "testMc3", "testMc4", "testMc5". As these animations are composed of the same 'sub' symbols, this (to me) makes more sense than having external SWF's.
Anyway what I want to do is load one of these movies into the Scene (this works), then on each respective timeline call a panning x+y position function, which will almost act as a camera, this makes more sense than physically animating each x,y movement.
The Main Doc Class looks like this:
package {
import flash.display.*;
import flash.events.*;
import flash.ui.*;
import flash.display.MovieClip;
import flash.utils.getDefinitionByName;
public class Test extends MovieClip {
public function moveCanvas(xPos, yPos){
//trace("hello world"+MovieClip(root).containerMc.x);
containerMc.x=xPos;//doesnt work 1120 Access of unidentified property containerMc
containerMc.y=yPos;//doesnt work 1120 Access of unidentified property containerMc
}
public function addCanvas(){
if(movieName==null){
var movieName:String="testMc"+2;
var C:Class=Class(getDefinitionByName(movieName));
var animC:MovieClip=new C();
var container:MovieClip = new MovieClip();
addChild(container);
container.name="containerMc";
container.addChild(animC);
}
}
public function startMenu(){
addCanvas();
}
}
}
now inside and on the respective timelines we have "textMc1", "testMc2" we have this action at crucial parts of the animations:
trace("mcComplete"+this.parent.name);
Object(root).moveCanvas(40,40);
stop();
The Error I get once the function call hits is:
1120 access of unidentified property containerMc1120 Access of unidentified property containerMc.
Any help would be greatly appreciated, or suggestions on how to make this better!
Thanks in advance.