Link to home
Start Free TrialLog in
Avatar of jack_p50
jack_p50

asked on

[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?
Avatar of Ramy_atef
Ramy_atef

Hi jack

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

Ramy
Avatar of jack_p50

ASKER

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.
Avatar of Aneesh Chopra
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
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
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.
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.
Cool...  That's good to know...  Thanks...  :)

CyanBlue
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).
ASKER CERTIFIED SOLUTION
Avatar of wings_gaurav
wings_gaurav

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Thanks, wings. I'll test it myself (with just linkage IDs and with linkage IDs and class names) and conclude this question.
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.
Just a note: both library names and as2 class names can be same across movie clips.
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
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.
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...
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
Too bad you don't have flash 8. I changed your test case's publish settings to flash player 8, no changes.