?
Solved

[actionscript] linkage identifiers conflict when using loadMovie

Posted on 2006-05-26
18
Medium Priority
?
523 Views
Last Modified: 2008-01-09
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?
0
Comment
Question by:jack_p50
  • 8
  • 4
  • 3
  • +2
18 Comments
 
LVL 7

Expert Comment

by:Ramy_atef
ID: 16769207
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
 
LVL 4

Author Comment

by:jack_p50
ID: 16769366
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
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16769857
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
Industry Leaders: 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 37

Expert Comment

by:CyanBlue
ID: 16773866
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
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16773934
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
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16773937
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
 
LVL 37

Expert Comment

by:CyanBlue
ID: 16773976
Cool...  That's good to know...  Thanks...  :)

CyanBlue
0
 
LVL 4

Author Comment

by:jack_p50
ID: 16776085
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
 
LVL 5

Accepted Solution

by:
wings_gaurav earned 2000 total points
ID: 16784626
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
 
LVL 5

Expert Comment

by:wings_gaurav
ID: 16784640
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
 
LVL 4

Author Comment

by:jack_p50
ID: 16784808
Thanks, wings. I'll test it myself (with just linkage IDs and with linkage IDs and class names) and conclude this question.
0
 
LVL 4

Author Comment

by:jack_p50
ID: 16796809
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
 
LVL 4

Author Comment

by:jack_p50
ID: 16796815
Just a note: both library names and as2 class names can be same across movie clips.
0
 
LVL 5

Expert Comment

by:wings_gaurav
ID: 16797181
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
 
LVL 4

Author Comment

by:jack_p50
ID: 16797222
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
 
LVL 4

Author Comment

by:jack_p50
ID: 16797347
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
 
LVL 5

Expert Comment

by:wings_gaurav
ID: 16797358
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
 
LVL 4

Author Comment

by:jack_p50
ID: 16797388
Too bad you don't have flash 8. I changed your test case's publish settings to flash player 8, no changes.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 how to record live broadcast.

807 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