Solved

LoadMovie is keeping Class references?!?!

Posted on 2004-09-28
7
193 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
[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
  • 3
  • 3
7 Comments
 
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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

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…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

696 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