Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


LoadMovie is keeping Class references?!?!

Posted on 2004-09-28
Medium Priority
Last Modified: 2010-04-03
Hi There,

im having some really strange issues with flash...

I have a fla that loads in external swf's when a user selects different menu items...
Each external swf has the same base classes [i.e. they all work off the same classes] but have the slightest variation to suit the different content being displayed [just like different array names and parameters]

However, for some reason, when I unload a swf and load the next, it keeps the first swf's class references and tries to apply that class to the new swf?
Then, as you progress into the program, you find it actually calls the functions from the first class rather than the packaged class.... very, very strange....

I have tried all types of unloadmovie, giving it different mc identifiers, everything....
I don't have any time to go through and change the class name to anything else, so I need to work with what I have got.

Does anyone know how to completly unload classes [that are compiled into swf's] so that new ones are loaded? I would have thought this would have been done automatically, but obviously im wrong....
Question by:d2kagw
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
  • 3
  • 3

Author Comment

ID: 12179004
ummmm.... im not sure where you were going with that?
but what does that tutorial have to do with loading and unloading dynamic classes?
LVL 10

Expert Comment

ID: 12179097
Industry Leaders: 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!


Author Comment

ID: 12185872
Thanks for that Muso,

It seems I have stumbled across J. Cheng's method of dynamically loading classes, however, I need to find out how to unload the classes...

Let me elaborate exactly whats happening....

Im having some really weird issues with loading external SWF's and its class files hanging around after the movie is unloaded....

Its kind of tricky to explain, but you can see it very clearly in this file...

Just run the main_stage.fla within flash [mx 04] and you'll see that if you click "Tester A" it will trace out "My Name is Tester A", then if you click on "Tester B" it will load a different swf, with a different class, but still trace out "My Name is Tester A" when it should be "My Name is Tester B"....

I have tried, unloading the swf's, removing the mc_Dropper and re-attaching it, re-declaring the variable testObj as null before declaring the class, basically everything  I can think of....

I really need help on this one, the deadline is looming and I can't afford to spend any more time on this....

LVL 10

Accepted Solution

muso120999 earned 2000 total points
ID: 12187829
Your code makes me confused!  Your as code cannot be in the same folder with the same name - Flash may have both loaded, but you need to be specific to tell it which class you want to reference.

I have fixed your example by doing the following...

TesterA.fla now has the code:
      var testObj : testera.tester
      testObj = new testera.tester()

testera.as (in the folder you gave me it in) has the code:
class testera.tester
      function tester ( )
            var tArgs : String = "Tester A"
            trace ( sendData ( tArgs ) )
      function sendData ( tArgs ) : String
            return "My Name is " + tArgs

and just substitute 'a' for 'b' for TesterB - bingo, it works!

I realise that this still may well leave you with problems, but there are a couple of key points here:

1. be specific about what class function you want to call
2. if functions are very similar, and likely overwriting eachother that is a problem, and I would try to incorporate them into one slightly more generic function (it's better if your code can be more flexible to accommodate more scenarios)

I guess there may be some workaround for you that I don't know about, but it looks like a situation better avoided if possible, as really, it isn't good practice.

Author Comment

ID: 12196874
Hi Muso,

thanks for the help...
Im aware that this isn't best practice, but I had to merge 3-4 different jobs [that have been developed over the past year] into one utility, and sadly, I didn't have the budget to go through and fix up the class issues, so I needed a quick fix.

Which you supplied, so thanks !
LVL 10

Expert Comment

ID: 12197510
Glad I was able to help!

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
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 motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

609 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