A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: AddChild movieclip to a frame

Hybrid View

  1. #1
    Member
    Join Date
    Aug 2008
    Posts
    38

    AddChild movieclip to a frame

    I have a project with a preloader.swf which loads: buttons (a board), settings.swf and game.swf.
    I want when in preloader's frame 1, to be visible the buttons.
    when in preloader's frame 2, to be visible the settings.swf.
    when in preloader's frame 3, to be visible the game.swf.

    But, with addChild movieClips are loaded to the first frime.
    So I added in frame 1, a movieclip Container1, and the button are added to Container1 (Container1.addChild button etc).
    In frame 2 I have Container2 (Container2.addChild settings.swf).
    In frame 3 I have Container3 (Container3.addChild game.swf).

    But it doesn't set the size and position of buttons, settings.swf and game.swf.

    Code:
    function onLoaded(e:Event):void {		
    	var movie:* =LoaderInfo(e.currentTarget).content;		
    
    	//Set size
    	movie.width=1366;
    	movie.height=700;
    		
    	//Adding content to the movieClip Container3
    	Container3.addChild(movie);
    
    	//Set size again
    	movie.width=1366;
    	movie.height=700;
    
    	movie.gotoAndStop("start");
    
    	// set position
    	movie.top=0;
    	movie.left=0;
    
    		
    }
    Last edited by panoss; 05-09-2015 at 06:18 AM.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Attach your *.flas, it's getting too complex to be able to try and mimick your files. All files.

  3. #3
    Member
    Join Date
    Aug 2008
    Posts
    38
    Here is a link to download because the forum board I suppose doesn't allow more than 1MB files:
    https://isxasos.sharefile.com/d-sd0ff10a565147b7a

    For simplicity, I 've not included the game.fla.
    Publish the settings.fla so that settings.swf will be created.
    It's in Flash CS4.

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Without going through it too much, bit messy though.

    Your main issue is the fact that Container1 and Container2 movieclips have different sizes.

    if you highlite Container1 or Container2 and check their sizes, then douible click it and check the inner sizes, they do not match.

    Make sure it is the same inside and outside, that will correct your sizing issues

    so Container1 movieClip needs to be 1366 width and 700 height both internally and externally, same with Container2

    or alternatively, you can leave them both as empty movie clips, which is probably better
    Last edited by fruitbeard; 05-09-2015 at 08:32 AM.

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