dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Draw objects to child movie? Help please!

  1. #1
    Junior Member
    Join Date
    Feb 2005
    Posts
    29

    Draw objects to child movie? Help please!

    Hi AS3 guru's, ive got a quick (hopefully) question for you. I have my main movie which includes a child movie, this child movie will move around the main movie and requires objects to be drawn within it... these objects should also move when the child movie moves. I have the code which draws the rectangles to the stage (the code runs within the child movie) but they wont move around when the child movie moves.

    Here is the code which i am using:
    Code:
    	spr_load3.graphics.beginFill(0xFFFFFF);
    	spr_load3.graphics.drawRect((234+loadpc),199,1,4);
    	spr_load3.graphics.endFill();
    	this.stage.addChild(spr_load3);
    Is there a way to add the children directly to the child movies stage? That way it would take into account the changing position of the movie and relocate the graphics based on the location of the child movie.

    I know a workaround would be to redraw the objects every frame after getting the new coordinates but i just wondered if there was a more simple way to do it. Sorry if i havent been too clear but im confusing myself here

    Thanks in advance!
    Andy

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You are confused about what the stage is. There is only one stage in your movie, period. By using "this.stage.addChild", you're referencing that one stage. What you probably want to do is simply remove the "stage" part of that to add spr_load3 directly to the movieclip.

    Code:
    	spr_load3.graphics.beginFill(0xFFFFFF);
    	spr_load3.graphics.drawRect((234+loadpc),199,1,4);
    	spr_load3.graphics.endFill();
    	addChild(spr_load3);

  3. #3
    Junior Member
    Join Date
    Feb 2005
    Posts
    29
    Quote Originally Posted by 5TonsOfFlax
    You are confused about what the stage is. There is only one stage in your movie, period. By using "this.stage.addChild", you're referencing that one stage. What you probably want to do is simply remove the "stage" part of that to add spr_load3 directly to the movieclip.

    Code:
    	spr_load3.graphics.beginFill(0xFFFFFF);
    	spr_load3.graphics.drawRect((234+loadpc),199,1,4);
    	spr_load3.graphics.endFill();
    	addChild(spr_load3);
    I knew it would be something simple! Thanks for that, works perfectly

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center