Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Unload swf movie AS2 inside swf AS3

Posted on 2008-11-13
9
Medium Priority
?
961 Views
Last Modified: 2013-11-11
Hi
I'm using Flash CS3 with Action Script 3, and I load a movie in AS2 insede another movie in AS3.
The code is
var contenedor = new Loader();
contenedor.load(new URLRequest("05_01_menu.swf"));
addChild(contenedor);
contenedor.x = 180
contenedor.y = 288

I don't know how to unload the movie to see the rest of the movie free and load another movies.

Thanks
0
Comment
Question by:yomiento
  • 4
  • 2
  • 2
8 Comments
 
LVL 39

Accepted Solution

by:
blue-genie earned 2000 total points
ID: 22953458
unload () method  

public function unload():void

Language Version :  ActionScript 3.0
Player Version :  Flash Player 9



Removes a child of this Loader object that was loaded by using the load() method. The property of the associated LoaderInfo object is reset to null. The child is not necessarily destroyed because other objects might have references to it; however, it is no longer a child of the Loader object.

As a best practice, before you unload a child SWF file, you should explicitly close any streams in the child SWF file's objects, such as LocalConnection, NetConnection, NetStream, and Sound objects. Otherwise, audio in the child SWF file might continue to play, even though the child SWF file was unloaded. To close streams in the child SWF file, add an event listener to the child that listens for the unload event. When the parent calls Loader.unload(), the unload event is dispatched to the child. The following code shows how you might do this:

function closeAllStreams(evt:Event) {
    myNetStream.close();
    mySound.close();
    myNetConnection.close();
    myLocalConnection.close();
}

myMovieClip.loaderInfo.addEventListener(Event.UNLOAD, closeAllStreams);
0
 

Author Comment

by:yomiento
ID: 22955026
Hi . I can't understand your answer. I a begeaner in Flash.

What I have to erase and what I have to put?
At the frame 106 I wrote this

var contenedor = new Loader();
contenedor.load(new URLRequest("05_01_menu.swf"));
addChild(contenedor);
contenedor.x = 180
contenedor.y = 288

And I would like to unload that movie on frame 111

I'd try to attach a .zip with the flash movie file the system didn't permited
Can you help me?
Thanks
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 22970180
you asked how to unload a movie.

contenedor.unloadMovie()
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:yomiento
ID: 22970277
Yes but I'm using AS3, and that doesn't work.
I would like to know how to unload a movie made in AS2 who was loaded in a previous frame with this script

var contenedor = new Loader();
contenedor.load(new URLRequest("05_01_menu.swf"));
addChild(contenedor);
contenedor.x = 180
contenedor.y = 288
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 22971273
arrgh its unload not unloadMovie as per my first post not my second one.
if you simply want to remove the loader and hence the content you can use removeChild.
0
 
LVL 2

Expert Comment

by:fsilva79
ID: 24238787
I have the same problem, can anyone help us please?

Blue-genie:
I totaly understand the idea you are showing in:
function closeAllStreams(evt:Event) {
    myNetStream.close();
    mySound.close();
    myNetConnection.close();
    myLocalConnection.close();
}

myMovieClip.loaderInfo.addEventListener(Event.UNLOAD, closeAllStreams);

but my problem is that I want to know if your variable "myMovieClip" is actually the varible :Loader
or what type of variable is it?
0
 
LVL 2

Expert Comment

by:fsilva79
ID: 24239064
ok, I found the solution and here it is how I managed to do it

ok, finaly I manage to solve this problem, i did the following:

import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
 
var loader:Loader = new Loader(); //this variable will load the file
var movieClip:MovieClip = new MovieClip();
 
...(your code here)
...(your code here)
...(your code here)
 
//then... i wrote my CloseButton function as follows:
 
private function closeMovieClip(evt:MouseEvent):void
{
	var movieClip:MovieClip = MovieClip(evt.currentTarget);
	movieClip.removeEventListener(MouseEvent.DOUBLE_CLICK, closeMovieClip);
	Tweener.removeTweens(movieClip);
		
	if(contains(movieClip))
		removeChild(movieClip);
		SoundMixer.stopAll();
		loader.unload();
}
/* the only downside of this is that if you had a background sound playing this command will stop ALL your sounds, special efects, music, whatever your flash is playing.*/

Open in new window

0
 
LVL 39

Expert Comment

by:blue-genie
ID: 24248223
close your question please.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
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…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

810 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