• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • Last Modified:

How to unload a movie ?

HI

I am loading a movie over a container like this:
function containYoutube(youtubevar, depthLevel) {
      this.createEmptyMovieClip("youtubecontainer",depthLevel);
      this.youtubecontainer.loadMovie("http://www.youtube.com/v/"+youtubevar);
}

but different videos are loaded at the same time in the same container, so I believe I should perform an instruction that could delete the instance created by createEmptyMovieClip in the previous event.

How to do that ?

Thanks
0
dimensionav
Asked:
dimensionav
  • 4
  • 4
1 Solution
 
Antonio EstradaCommented:
Try

removeMovieClip(this.youtubecontainer);

That should work.

Good luck,
-V
0
 
dimensionavAuthor Commented:
I have on release event the following:

on (release)
{
      Security.allowDomain('http://www.youtube.com');
      Security.allowDomain('http://gdata.youtube.com');
      Security.allowInsecureDomain('http://gdata.youtube.com');
      Security.allowInsecureDomain('http://www.youtube.com');
      
      function containYoutube(youtubevar, depthLevel) {
            removeMovieClip(mcDestino);
            mcDestino.createEmptyMovieClip("youtubecontainer",depthLevel);
            mcDestino.youtubecontainer.loadMovie("http://www.youtube.com/v/"+youtubevar);
      }
      
      containYoutube("my string of URL video", mcDestino.getNextHighestDepth());
}

After clicking in different buttons the previous video is still loaded and it plays at the same time of new ones.
0
 
dimensionavAuthor Commented:
The buttons and the video container are in the same level (inside other movieclips)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Antonio EstradaCommented:
That's odd, how about

removeMovieClip(mcDestino.youtubecontainer);
unloadMovie(mcDestino.youtubecontainer);

If this doesn't work, can you upload your fla so I can take a look at it?

Good luck.

-V
0
 
dimensionavAuthor Commented:
The file has confidential content, could I send it to you by email?
0
 
Antonio EstradaCommented:
Sure thing, you can look it up on my profile.

-V
0
 
dimensionavAuthor Commented:
Sent
0
 
Antonio EstradaCommented:
Ok so here's a working version.

You need to delete all the code that you have on each button (all those on(release)), name them "btn1" for the first one, "btn2" and so on. Then add a new layer on the main timeline, there add the code (just like you have it on mcDestino, which should also go away).

Then add this code:

var ytLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
var dataArray:Array = [{id: 1, link: "link1"},
					   {id: 2, link: "link2"},
					   {id: 3, link: "link3"},
					   {id: 4, link: "link4"},
					   {id: 5, link: "link5"}];
      
startUp();

function startUp():Void
{
	Security.allowDomain('http://www.youtube.com');
	Security.allowDomain('http://gdata.youtube.com');
	Security.allowInsecureDomain('http://gdata.youtube.com');
	Security.allowInsecureDomain('http://www.youtube.com');
	listener.onLoadComplete = videoLoaded;
	ytLoader.addListener(listener);
	var n:Number = dataArray.length;
	for(var i:Number = 1; i <= n; i++)
	{
		this["btn" + i].onRelease = loadYouTubeVideo;
		this["btn" + i].link = dataArray[i - 1].link;
	}
	loadVideo(dataArray[0].link);
}

function loadYouTubeVideo():Void
{
	mcDestino.destroy();
	loadVideo(this.link);
}

function loadVideo(cLink:String):Void
{
	ytLoader.loadClip("http://www.youtube.com/v/" + cLink, mcDestino);
}

Open in new window


Replace "link1" with the actual link.

Good luck!
-V
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now