Solved

How would you remove SWF's?

Posted on 2010-11-17
9
307 Views
Last Modified: 2012-05-10
So I have a problem occurring when I try the addChild/removeChild method. Maybe, I am doing something wrong, but my question is that when you click on a gallery page and its time to load the SWF... it loads fine, but when its time to remove the SWF that is where the problem is occurring. I don't get any errors when I output the movie, but when I click links, the following problem persists:

TypeError: Error #2007: Parameter child must be non-null.
      at flash.display::DisplayObjectContainer/removeChild()
      at nali_Project_3_Portfolio_fla::MainTimeline/frame10()
      at flash.display::MovieClip/gotoAndStop()
      at nali_Project_3_Portfolio_fla::intro_mc_1/frame108()

What seems to be the problem here? My code is as follows:
var requestMov:URLRequest = new URLRequest("gallery.swf");
var loaderMov:Loader = new Loader();
addChild(loaderObj);
loaderMov.load(requestMov);

Open in new window

and to remove it is removeChild(loaderObj).
0
Comment
Question by:beginnersdevelopment
  • 6
  • 3
9 Comments
 

Author Comment

by:beginnersdevelopment
Comment Utility
Needs attention quick!
0
 
LVL 5

Expert Comment

by:GarrettChristopherson
Comment Utility
change addchild(loaderObj) to addchlid(loaderMov)
0
 

Author Comment

by:beginnersdevelopment
Comment Utility
fixed, but not working still.

var requestMov:URLRequest = new URLRequest("gallery.swf");
var loaderMov:Loader = new Loader();
addChild(loaderMov);
loaderMov.load(requestMov);

Open in new window


and to remove: removeChild(loaderMov).

Still get an error. Whats the problem or is there another way of removing and adding swf's?
0
 
LVL 5

Expert Comment

by:GarrettChristopherson
Comment Utility
what error are you getting?
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:beginnersdevelopment
Comment Utility
I am getting a lot of type errors when I test the movie out, but when I don't link my SWF's than I am good to go. My question turns around to be... What is the AS 3.0 code for adding and removing a swf file? I have researched this, but no solutions seem to work for me? Here is a preview of what I am doing: I am putting two galleries (gallery.swf and gallertwo.swf) in to a flash website. The code that I am using to put the SWF on my website is

var gallery:Loader = new Loader();
gallery.load(new URLRequest("nali_Project_3_gallery.swf"));
addChild(gallery);

Open in new window


and to remove it is

removeChild(gallery);

Open in new window


I use the same code with different function name for gallerytwo, but no luck and just errors like "TypeError: Error #2007: Parameter child must be non-null.
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller."

gallerytwo doesn't get removed successfully either, but the other gallery does.

What am I doing wrong and what is the right script to do this? Am I adding the code to each button or what? I am bumping this up to 500 points, so someone please quickly help me.
0
 

Author Comment

by:beginnersdevelopment
Comment Utility
I commented out the
removeChild

Open in new window

code and it seems to work without any errors, so the problem has to be that or that I am not putting the wrong code.  If I don't put this piece of code to remove SWF than my SWF's sit on top of the other pages. What am I doing wrong, somebody?
0
 
LVL 5

Accepted Solution

by:
GarrettChristopherson earned 500 total points
Comment Utility
This is just a hunch:  I believe that your problem is scope, or when removeChild functions are called on the timeline. Along the lines of when removeChild is called on the timeline, try this:

var gallery:Loader = new Loader();
gallery.name = "gallery";
gallery.load(new URLRequest("nali_Project_3_gallery.swf"));
addChild(gallery);

and then just before you remove it from the stage, call

trace(gallery.name + " = gallery.name");  

do that for both of your loader objects, if you get an error with the trace(), try to find the place that the trace will report/print the name.  

as far as the #2025, this has to do with scope.

scope works likes this:

var mc:MovieClip = new MovieClip();
var gallery:Loader = new Loader();
gallery.load(new URLRequest("nali_Project_3_gallery.swf"));
mc.addChild(gallery); //this command makes gallery a child of mc

if you try: removeChild(gallery);  // it should throw a #2025 exception because you need to associate the relationship (parent & child).

where as mc.removeChild(gallery); //should remove gallery from the stage.

hope that helps
0
 

Author Comment

by:beginnersdevelopment
Comment Utility
I got the solution, but noone on here helped as much as I would like. Thanks everyone for the help and I rewarded the points to the best solution I got.
0
 

Author Closing Comment

by:beginnersdevelopment
Comment Utility
I found the answer at another EE. I love this  site.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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

12 Experts available now in Live!

Get 1:1 Help Now