Solved

How to unload a movie ?

Posted on 2011-02-15
8
299 Views
Last Modified: 2012-05-11
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
Comment
Question by:dimensionav
  • 4
  • 4
8 Comments
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 34901207
Try

removeMovieClip(this.youtubecontainer);

That should work.

Good luck,
-V
0
 

Author Comment

by:dimensionav
ID: 34958789
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
 

Author Comment

by:dimensionav
ID: 34958800
The buttons and the video container are in the same level (inside other movieclips)
0
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 34961732
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:dimensionav
ID: 34965575
The file has confidential content, could I send it to you by email?
0
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 34965653
Sure thing, you can look it up on my profile.

-V
0
 

Author Comment

by:dimensionav
ID: 34968731
Sent
0
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 500 total points
ID: 34976845
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now