03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Occasionally, you might encounter the following situation. Suppose you load a child SWF file<br />

from a different domain. You want to implement this method so that the child SWF file can<br />

make LocalConnection calls to the parent SWF file, but you don't know the final domain<br />

from which the child SWF file will come. This can happen, for example, when you use loadbalancing<br />

redirects or third-party servers.<br />

In this situation, you can use the MovieClip._url property in your implementation of this<br />

method. For example, if you load a SWF file into my_mc, you can then implement this<br />

method by checking whether the domain argument matches the domain of my_mc._url.<br />

(You must parse the domain out of the full URL contained in my_mc._url.)<br />

If you do this, make sure that you wait until the SWF file in my_mc is loaded, because the _url<br />

property will not have its final, correct value until the file is completely loaded. The best way<br />

to determine when a child SWF file finishes loading is to use<br />

MovieClipLoader.onLoadComplete.<br />

The opposite situation can also occur: You might create a child SWF file that wants to accept<br />

LocalConnection calls from its parent but doesn't know the domain of its parent. In this<br />

situation, implement this method by checking whether the domain argument matches the<br />

domain of _parent._url. Again, you must parse the domain out of the full URL from<br />

_parent._url. In this situation, you don't have to wait for the parent SWF file to load; the<br />

parent will already be loaded by the time the child loads.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 7<br />

Parameters<br />

sendingDomain:String [optional] - A string that specifies the domain of the SWF file that<br />

contains the sending LocalConnection object.<br />

Example<br />

The following example shows how a LocalConnection object in a receiving SWF file can<br />

permit SWF files from any domain to invoke its methods. Compare this to the example in<br />

LocalConnection.connect(), in which only SWF files from the same domain can invoke<br />

the trace() method in the receiving SWF file. For a discussion of the use of the underscore<br />

(_) in the connection name, see LocalConnection.send().<br />

this.createTextField("welcome_txt", this.getNextHighestDepth(), 10, 10,<br />

100, 20);<br />

var my_lc:LocalConnection = new LocalConnection();<br />

my_lc.allowDomain = function(sendingDomain:String) {<br />

domain_txt.text = sendingDomain;<br />

return true;<br />

};<br />

724 <strong>ActionScript</strong> classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!