I was having a few issues with urls when using an external swf and loading it into a swf in a different folder. I have now decided to go into my main swf and make movieclips instead for each different page. I have created a movieclip on my stage and given it an instance. I am now trying to contain an image gallery within this (I go into the movieclip to code). The code I am using is
var container_x:Number = this.width * 0.5;
var container_y:Number = this.height * 0.5 + 160;
var container:Sprite = new Sprite();
container.x = container_x;
container.y = container_y;
addChild(container);
var scene:Scene3D = new MovieScene3D(container);
var cam:Camera3D = new Camera3D();
cam.zoom = 6;
However, this still goes onto my main stage. I have tried doing things like parent.myMovieClip and root.myMovieClip to no avail. I was then hoping the keyword this would then relate to the movieclip I was in, but it does not seem to. How would it be possible for everything I make within this movieclip to stay contained within it?
Thanks
that's strange. if the code you provided is "written in" the MovieClip's timeline, than you are definitely addressing correct objects. the keyword "this" would in deed mean the owner of the timeline containing the script. so if the 3D scene is rendered in the main stage, I would guess that the 3D engine you are using always uses the stage to render itself. what engine are you using anyway?
Thanks. I am using papervision 3D. On the main stage, I drew a rectangle and converted it to a movieclip. I then double clicked on it to enter it and I am now working within it. I dont have any experience in papervision, so I am not sure if they render it straight to the main stage.
Just noticed some render code at the bottom which might make a difference, not to sure though
addEventListener(Event.ENTER_FRAME, render);
function render(e:Event):void
{
var distance_x:Number = (stage.mouseX - 400) * 0.0001;
angle += distance_x;
cam.x = - Math.cos(angle) * 150;
cam.z = Math.sin(angle) * 150;
scene.renderCamera(cam);
}
I changed stage to this, and it makes the gallery disappear like it is suppossed too. Still fails to be contained within the movieclip though.
this script seems to control the camera by mouse interaction. when you move mouse from left to right, the camera should move in the circle.
hm, what do you mean by "contained"? you mean that it should't be bigger than the rectangle you drew? I took a look at the papervision documentation and believe that the 3d scene is rendering inside the movie clip you created.
your movieclip being a "container" means only one thing: every object on your MovieScene3D is going to be child of the container.
if you don't want the MovieScene3D to go out of "the box", you should use mask.
1) open the MovieClip with the rectangle in it
2) select the rectangle
3) create a MovieClip
4) give it an instance name lets say "sceneMask"
5) modify the code:
var container_x:Number = this.width * 0.5;
var container_y:Number = this.height * 0.5 + 160;
var container:Sprite = new Sprite();
container.x = container_x;
container.y = container_y;
container.mask = getChildByName("sceneMask");
addChild(container);
var scene:Scene3D = new MovieScene3D(container);
var cam:Camera3D = new Camera3D();
cam.zoom = 6;
I will actually give that a go. Fantastic, that seemed to have done the job. I just have to correct the sizes. So in essense, the container is now the mask? It is strange why it wasnt working without the mask, when I get time I will problably go back and see if I can figure it out. Thanks a lot for your help, I am sure I will be needing it again soon :-)
you're welcome
well, the "container" holds every object of the MovieCcene3D, it is not the mask - it is masked by the square - "sceneMask".
you see, MovieClips don't have boundaries. the fact you drawn a rectangle in it doesn't mean anything - you can draw another thousand of objects, squares, lines.. they don't get masked by the first object drawn. if you want any MovieClip to be masked, you have to say so, by
my_mc.mask = another_mc;
North America
Europe, Middle East and Africa
Asia Pacific