A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [AS3]loadmovie+unloadmovie

  1. #1
    Junior Member
    Join Date
    Dec 2005
    Posts
    25

    [AS3]loadmovie+unloadmovie

    Hi, i have a small problem. Ive got three mc's which i use as a links. AS looks like this:
    Code:
    stop();
    /////////////////////////////////
    import flash.events.MouseEvent;
    import flash.display.*;
    import flash.utils.getDefinitionByName;
    /////////////////////////////////
    function addMovieFromLibraryOmnie(mcIName:String){
    	var tMC:Class =  getDefinitionByName(mcIName) as Class;
    	var newMc:MovieClip = new tMC() as MovieClip;
    	removeChild(newMc);
    	newMc.x=517;
    	newMc.y=-234;
    	addChild(newMc);
    }
    function addMovieFromLibraryGaleria(mcIName:String){
    	var tMC:Class =  getDefinitionByName(mcIName) as Class;
    	var newMc:MovieClip = new tMC() as MovieClip;
    	newMc.x=517;
    	newMc.y=-234;
    	addChild(newMc);
    }
    function addMovieFromLibraryKontakt(mcIName:String){
    	var tMC:Class =  getDefinitionByName(mcIName) as Class;
    	var newMc:MovieClip = new tMC() as MovieClip;
    	newMc.x=517;
    	newMc.y=-234;
    	addChild(newMc);
    }
    /////////////////////////////////
    omnie.buttonMode = true; 
    omnie.addEventListener (MouseEvent.CLICK, omnia);
    omnie.addEventListener (MouseEvent.ROLL_OVER, omnia01);
    omnie.addEventListener (MouseEvent.ROLL_OUT, omnia02);
    
    function omnia ($event:MouseEvent) {
    	tabbg.gotoAndPlay(2);
    	addMovieFromLibraryOmnie("tekst");
    }
    function omnia01 ($event:MouseEvent) {omnie0.gotoAndPlay(2);}
    function omnia02 ($event:MouseEvent) {omnie0.gotoAndPlay(6);}
    /////////////////////////////////
    galeria.buttonMode = true;
    galeria.addEventListener (MouseEvent.CLICK, galery);
    galeria.addEventListener (MouseEvent.ROLL_OVER, galery01);
    galeria.addEventListener (MouseEvent.ROLL_OUT, galery02);
    function galery ($event:MouseEvent) {tabbg.gotoAndPlay(2);}
    function galery01 ($event:MouseEvent) {galeria0.gotoAndPlay(2);}
    function galery02 ($event:MouseEvent) {galeria0.gotoAndPlay(6);}
    /////////////////////////////////
    kontakt.buttonMode = true;
    kontakt.addEventListener (MouseEvent.CLICK, contact);
    kontakt.addEventListener (MouseEvent.ROLL_OVER, contact01);
    kontakt.addEventListener (MouseEvent.ROLL_OUT, contact02);
    function contact ($event:MouseEvent) {tabbg.gotoAndPlay(2);}
    function contact01 ($event:MouseEvent) {kontakt0.gotoAndPlay(2);}
    function contact02 ($event:MouseEvent) {kontakt0.gotoAndPlay(6);}
    /////////////////////////////////
    I want to solve my problem - loading and unloading movies from library. For example:

    when you click on galeria,omnie or kontakt it will display tabbg (which is on the stage) and some mc from library. The biggest problem is that there is possiblity that when you will click on galeria and next on omnie - on stage will be displayed both. Ive tried to make some functions - one function for adding sth from library and other to remove the child but it came for nothing;/ is there any way to solve it? I ask because if it comes to as2 there are no problems. But in as3..;/ please help

  2. #2
    Member
    Join Date
    Mar 2007
    Posts
    79
    Will something like this work for you?
    PHP Code:
    function removeMC () {
       while (
    movieClipName.numChildren 0) {
          
    movieClipName.removeChildAt(0);
        }


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