?
Solved

How would you remove SWF's?

Posted on 2010-11-17
9
Medium Priority
?
316 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 

Author Comment

by:beginnersdevelopment
ID: 34156405
Needs attention quick!
0
 
LVL 5

Expert Comment

by:GarrettChristopherson
ID: 34156716
change addchild(loaderObj) to addchlid(loaderMov)
0
 

Author Comment

by:beginnersdevelopment
ID: 34156974
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
Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

 
LVL 5

Expert Comment

by:GarrettChristopherson
ID: 34157292
what error are you getting?
0
 

Author Comment

by:beginnersdevelopment
ID: 34159432
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
ID: 34159521
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 1000 total points
ID: 34159574
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
ID: 34160001
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
ID: 34160009
I found the answer at another EE. I love this  site.
0

Featured Post

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

719 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