Solved

LoadMovie is keeping Class references?!?!

Posted on 2004-09-28
7
191 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
Independent Software Vendors: 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!

 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Embedding Flash App/Movie on Website 3 508
Stop Ads in Browser Google Chrome 3 551
free photo watermark software 5 101
Adobe Products Forum? 3 165
This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

685 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