LoadMovie is keeping Class references?!?!

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....
LVL 3
d2kagwAsked:
Who is Participating?
 
muso120999Connect With a Mentor Commented:
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.
0
 
d2kagwAuthor Commented:
ummmm.... im not sure where you were going with that?
but what does that tutorial have to do with loading and unloading dynamic classes?
0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
muso120999Commented:
0
 
d2kagwAuthor Commented:
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... http://69.0.250.15/What_the.zip

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....

Cheers
0
 
d2kagwAuthor Commented:
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 !
0
 
muso120999Commented:
Glad I was able to help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.