Solved

LoadMovie is keeping Class references?!?!

Posted on 2004-09-28
7
190 Views
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....
0
Comment
Question by:d2kagw
  • 3
  • 3
7 Comments
 
LVL 6

Expert Comment

by:nishasrilankan
ID: 12177945
0
 
LVL 3

Author Comment

by:d2kagw
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?
0
 
LVL 10

Expert Comment

by:muso120999
ID: 12179097
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 3

Author Comment

by:d2kagw
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... 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
 
LVL 10

Accepted Solution

by:
muso120999 earned 500 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.
0
 
LVL 3

Author Comment

by:d2kagw
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 !
0
 
LVL 10

Expert Comment

by:muso120999
ID: 12197510
Glad I was able to help!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
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): …
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

776 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