[actionscript] linkage identifiers conflict when using loadMovie

My main movie clip (lesson.swf) contains a symbol with linkage identifier "window".
I have another movie clip (grapher.swf, totally stand-alone application) which also contains a symbol with linkage identifier "window" (totally unrelated to the 1st one).
I have a button in lesson.swf, it's onRelease code does the following:
{
  var mc = createEmptyMovieClip('grapher', getNextHighestDepth());
  mc.loadMovie('grapher.swf')
}

I have another button which attaches a "window" symbol from the library to the root movie clip.
After I click the button that opens grapher, this second button no longer works. I've debugged the problem, and
found out the following - as soon as grapher is loaded, trying to attachMovie a "window" symbol somehow tries to attach the "window" library symbol from grapher.swf.
How do I make the two movies isolated from each other? I.e., I don't know their library assets exported for actionscript conflicting?
LVL 4
jack_p50Asked:
Who is Participating?
 
wings_gauravCommented:
Hi,

I did try it out and it works properly.

code on button one
on(release)
{
      _root.attachMovie("window", "test1", _root.getNextHighestDepth());
}

code on button two
on(release)
{
      var mc = createEmptyMovieClip('grapher', getNextHighestDepth());
      mc._lockroot = true;
      mc.loadMovie('grapher.swf');
}

on first frame of the grapher clip:
_root.attachMovie("window", "test1", _root.getNextHighestDepth());

Test case executed: click second button - the grapher clip loads and shows the content from it's library too. thereafter click first button - the clip from the lesson movie's library is loaded.

so far so good all works well - maybe i am missing something.

The problem is with the as2 class names. If the class names have conflicting path names then there is a definate problem. Much like a java JVM a swf has one virtual machine and any conflicts in the fully qualified path names will cause only the first class to load. So in this case the constructor of the window class is lesson swf get's callled even when the movie being loaded is the one inside the grapher library.

-wings
0
 
Ramy_atefCommented:
Hi jack

Why don't you simply change the identify name for one of the tow movies and solve this problem of confilict ??

Ramy
0
 
jack_p50Author Commented:
I did just that, but that's a "hack". The stuff works now, but I wanna know why this shit happens.
I.e., how flash determines from which library to get the symbol.

Someday I might have to use someone else's movie (for which I don't have the source) which breaks my movie, chaging ids can be troublesome if they're referenced in a lot of places. Or, for example, if I need to use two 3rd-party movies (no source), both of which have conflicting ids - I would't be able to changed either of them.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Aneesh ChopraCommented:
this is not a "hack", this is only solution and the correct way to fix this kind of problem...

if two different swfs has movieClips with same linkageID than second one will definately fails, in simple words first one will override the second one.

Rgds
Aneesh
0
 
CyanBlueCommented:
I do agree with Aneesh on that...  That's the only way you can get things work...  

Aneesh...  Isn't the second one overwrite the first one not the other way around???

CyanBlue
0
 
Aneesh ChopraCommented:
CyanBlue,

for your clarification,
No second one will not overwrite the first one.

movieClip with linkageID gets intiated only once in start, all further calls to same linkageID/movieClip uses the instance of intiated movieClip, thats so all further loaded movieClips with similar linkageID will be ingored.

I hope it will be cleared.
0
 
Aneesh ChopraCommented:
just addition to my previous comment:
I WROTE:
"thats so all further loaded movieClips with similar linkageID will be ingored."

ignored means here, flash will create a instance of firstly loaded movieClip.
0
 
CyanBlueCommented:
Cool...  That's good to know...  Thanks...  :)

CyanBlue
0
 
jack_p50Author Commented:
That's strange. So, there's no isolation between swf files.
What if I got some two 3rd-party swfs (no source) that I'd like to load inside my movie, and they both contain symbols with conflicting linkage id - no solution at all?

aneesh, you're telling me:
"movieClip with linkageID gets intiated only once in start, all further calls to same linkageID/movieClip uses the instance of intiated movieClip, thats so all further loaded movieClips with similar linkageID will be ingored."

But my code displays other behaviour.

lesson.swf has a symbol with linkageID "window".
When I press button1, an instance of window is attached. I close this window. So far, it works fine.
I then press button2, which creates an empty movie clip and loads grapher.swf inside it. The grapher.swf clip also has a symbol with linkageID "window" in it. The grapher works fine. I close the grapher window.
Now when I press button1 again, nothing happens. A few "trace" statements and all is revealed - this time, the constructor of grapher's "window" is called (both lesson's and grapher's "window" has a corresponding "window" classes).
0
 
wings_gauravCommented:
Just to summarize - the library names can remain same across movie clips without any problems but the as2 class names can't. Recommendation would be to use package names to avoid conflict.

-wings
0
 
jack_p50Author Commented:
Thanks, wings. I'll test it myself (with just linkage IDs and with linkage IDs and class names) and conclude this question.
0
 
jack_p50Author Commented:
I've made a test case and seems aneesh was wrong - it does work. I couldn't reproduce my original problem at all. Symbols with equal linkage IDs and class names (but different classes) both work!
If anyone's interested, here's the test case http://heilong.oceanography.ru/flash/tests/id_and_classname_conflict.zip
As wings provided an almost correct answer backed with real tests done, points go to him.
0
 
jack_p50Author Commented:
Just a note: both library names and as2 class names can be same across movie clips.
0
 
wings_gauravCommented:
Hi jack,

http://www.4shared.com/file/1849666/52f021b5/testcase.html

Here is the test case i used. Notice if the grapher is loaded into lesson then the constructor (trace) of "window" from the lesson is called although the clip shown is from the library of "grapher". I.e. the clip is visually the one from the other movies library but the attached as2 class loads incorrectly.

-wings
0
 
jack_p50Author Commented:
I'll check it out. I want to notice that I used trace in my test case too, and it was right both visually and the trace string was correct, too.
0
 
jack_p50Author Commented:
In your test_case, indeed, lesson's Window class is used all the time. Strange!
My test case is very similar and it works the other way there...
0
 
wings_gauravCommented:
i couldn't see your test case - don't have flash 8. I am using flash mx 2004 professional and target player 7 - maybe that is what is causing the difference.

-wings
0
 
jack_p50Author Commented:
Too bad you don't have flash 8. I changed your test case's publish settings to flash player 8, no changes.
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.