Skip navigation
Currently Being Moderated

containing issue

Oct 28, 2011 3:38 PM

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

 
Replies
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Oct 28, 2011 3:56 PM   in reply to nick2price

    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?

     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Oct 28, 2011 4:16 PM   in reply to nick2price

    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.

     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Oct 28, 2011 4:36 PM   in reply to Peter Celuch

    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;
    
     
    |
    Mark as:
  • Peter Celuch
    505 posts
    Nov 17, 2005
    Currently Being Moderated
    Oct 28, 2011 4:54 PM   in reply to nick2price

    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;
    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points