# Problem with attachMovie

**URL:** <https://forum.kirupa.com/t/problem-with-attachmovie/249805>\
**Category:** Uncategorized\
**Created:** [January 22, 2008, 5:48pm UTC](https://forum.kirupa.com/t/problem-with-attachmovie/249805 "2008-01-22T17:48:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BDore](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@BDore](https://forum.kirupa.com/u/BDore)\
**Post date:** [January 22, 2008, 5:48pm UTC](https://forum.kirupa.com/t/problem-with-attachmovie/249805/1 "2008-01-22T17:48:00Z")

</div>

Hi guys!

So…I’m sure the answer to this is quite simple but I’ve ran out of patience. Please help. =)

I’m building a media player for a website and this is my code, in the first frame of the main timeline:

[AS]stop();  
this.\_lockroot = true;  
import mx.controls.MediaDisplay;  
var \_display:MediaDisplay;

/\* ESCONDE CONTROLES \*/  
btnPlay.\_visible =  
btnStop.\_visible =  
btnPause.\_visible =  
btnSom.\_visible =  
mcProgresso.\_visible =  
youtube.\_visible = false;

//LINE BELOW IS THE SUBJECT OF THIS TOPIC  
this.attachMovie(“bot\_som\_off”, “btnSomOff”, this.getNextHighestDepth());

System.useCodepage = true;

// GLOBAIS  
mcPag2.\_visible = false;  
var somAtivo:Number = 1;

//loadMovie((nomeVideo + “.jpg”), mcPlayer.mcPreview);

btnPlay.onRelease = function(){  
\_root.mcPlayer.mcDisplay.play();  
\_root.mcPlayer.mcPreview.\_visible = false;  
}

btnPause.onRelease = function(){  
\_root.mcPlayer.mcDisplay.pause();  
}

btnStop.onRelease = function(){  
\_root.mcPlayer.mcDisplay.stop();  
}

btnSom.onRelease = function(){  
trace(\_root.somAtivo);  
if(\_root.somAtivo == “1”){  
\_root.mcPlayer.mcDisplay.volume = 0;  
\_root.somAtivo = “0”;  
this.gotoAndStop(2);  
}else{  
\_root.mcPlayer.mcDisplay.volume = 100;  
\_root.somAtivo = “1”;  
this.gotoAndStop(1);  
}  
}

youtube.btnYoutube.onRelease = function(){  
unloadMovie(mcThumb);  
\_root.mcPlayer.mcDisplay.contentPath = “angela.flv”;  
\_root.mcPlayer.mcDisplay.play(0);  
\_root.progressoVideo();  
\_root.youtube.\_visible = false;  
\_root.container.\_visible =  
\_root.btnPlay.\_visible =  
\_root.btnStop.\_visible =  
\_root.btnPause.\_visible =  
\_root.btnSom.\_visible =  
\_root.mcProgresso.\_visible = true;  
play();  
}

function progressoVideo(){  
var timer = setInterval(function(){  
if(\_root.mcPlayer.mcDisplay.playing == true){  
var atual = \_root.mcPlayer.mcDisplay.playheadTime  
var total = \_root.mcPlayer.mcDisplay.totalTime  
var perc = (atual \* 100)/total;  
\_root.mcProgresso.barra.\_xscale = perc;  
}else{  
clearInterval(timer);  
}  
},100);  
}

/\* PRELOAD THUMBNAIL _/  
var pagina = “angela.jpg”;  
/_ \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*/

my\_mc = new MovieClipLoader();  
preload = new Object();  
my\_mc.addListener(preload);  
preload.onLoadStart = function(targetMC) {  
//trace("Começou: "+targetMC);  
mcPreloader.\_visible = true;  
container.\_visible = false;  
};

preload.onLoadProgress = function(targetMC, lBytes, tBytes) {  
//bar.\_width = (lBytes/tBytes)\*100;  
mcPreloader.pText.text = Math.round((lBytes/tBytes)\*100) + “%”;  
//trace(Math.round((lBytes/tBytes)\*100));  
};

preload.onLoadComplete = function(targetMC) {  
mcPreloader.\_visible = false;  
youtube.\_visible = true;  
//trace(targetMC+" Terminou!");  
};

my\_mc.loadClip(pagina, “mcPlayer.mcPreview”);[/AS]

Button is being loaded correctly with this. The thing is I want to load the button inside a movieclip called \*containerSOM \*which is already on the stage. I tried in the main timeline:

```auto
this.containerSom.attachMovie("bot_som_off", "btnSomOff", this.getNextHighestDepth());
_root.containerSom.attachMovie("bot_som_off", "btnSomOff", this.getNextHighestDepth());
containerSom.attachMovie("bot_som_off", "btnSomOff", this.getNextHighestDepth());

```

And in the first frame of _containerSom_ I also tried:

```auto
this.attachMovie("bot_som_off", "btnSomOff", this.getNextHighestDepth());

```

None of these worked. This is very weird…an instance path problem? Am I blind and missed something obvious?

There are other ways to do this but I really want to try figuring this out…

thx a lot!!
