# XML/AS - Is this even possible?

**URL:** <https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707>\
**Category:** flash\
**Created:** [March 20, 2006, 9:52pm UTC](https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707 "2006-03-20T21:52:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![quandary23](https://avatars.discourse-cdn.com/v4/letter/q/f04885/32.png) [@quandary23](https://forum.kirupa.com/u/quandary23)\
**Post date:** [March 20, 2006, 9:52pm UTC](https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707/1 "2006-03-20T21:52:33Z")

</div>

I know there aren’t supposed to be any stupid questions, but…

I’m working on a site for a friend’s art gallery.

I have a dynamic html file I’m using to list an archive of shows so that it can be easily updated by the curator.

**Is it possible to code a link in the externally loaded xml file that will tell my flash movie to load an external swf into an empty mc on the root?**

I’m new to XML speak, so pardon me if I butcher it, but is there a way to:

create a variable in AS that when added to the xml file, triggers something like **loadMovie(“g\_0306.swf”, “\_root.empty”);**??

I’m under the wire, and bummed that I’m beginning to think I need to redo the upcoming/past show listings altogether…

Thanks

---

<div class="post-metadata">

**Author:** ![goingNuts](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@goingNuts](https://forum.kirupa.com/u/goingNuts)\
**Post date:** [March 21, 2006, 12:17am UTC](https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707/2 "2006-03-21T00:17:49Z")

</div>

> [@quandary23](#):
>
> I know there aren’t supposed to be any stupid questions, but…
> 
> I’m working on a site for a friend’s art gallery.
> 
> I have a dynamic html file I’m using to list an archive of shows so that it can be easily updated by the curator.
> 
> **Is it possible to code a link in the externally loaded xml file that will tell my flash movie to load an external swf into an empty mc on the root?**
> 
> I’m new to XML speak, so pardon me if I butcher it, but is there a way to:
> 
> create a variable in AS that when added to the xml file, triggers something like **loadMovie(“g\_0306.swf”, “\_root.empty”);**??
> 
> I’m under the wire, and bummed that I’m beginning to think I need to redo the upcoming/past show listings altogether…
> 
> Thanks

You could make a variable in AS that stands for whatever node your dynamic .swf is and whenever it’s triggered write:

```auto

node = this.firstChild.childNodes.childNodes*.childNodes[0].firstChild.nodeValue;
//whatever triggers the event
loadMovie(node, _root.empty);

```

or what have you…

---

<div class="post-metadata">

**Author:** ![dreeft](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@dreeft](https://forum.kirupa.com/u/dreeft)\
**Post date:** [March 21, 2006, 12:19am UTC](https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707/3 "2006-03-21T00:19:17Z")

</div>

That should work, yes.

---

<div class="post-metadata">

**Author:** ![quandary23](https://avatars.discourse-cdn.com/v4/letter/q/f04885/32.png) [@quandary23](https://forum.kirupa.com/u/quandary23)\
**Post date:** [March 21, 2006, 2:50am UTC](https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707/4 "2006-03-21T02:50:53Z")

</div>

Thanks for the swift response! VERY much appreciated, not to mention quite a surprise because in a fidgety expression of panic, I diagrammed my issues out for the kirupaverse.

The diagram might serve some good, as I’m not totally sure I properly explained myself the first time…

In regards to your script:

node = this.firstChild.childNodes.childNodes\*.childNodes[0].firstChild.nodeValue;  
**//whatever triggers the event**  
loadMovie(node, \_root.empty);

I think it’s the “ **whatever triggers the event** ” part that I’m uncertain about.

Here’s what I’m trying to accomplish (now in diagramtic, drop-shadowed form!).

Hope it makes sense and correlates with my question. If so, it will make my questions a lot easier to ask.

Thanks for looking!

🙂

Thank you!

---

<div class="post-metadata">

**Author:** ![quandary23](https://avatars.discourse-cdn.com/v4/letter/q/f04885/32.png) [@quandary23](https://forum.kirupa.com/u/quandary23)\
**Post date:** [March 21, 2006, 5:29am UTC](https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707/5 "2006-03-21T05:29:50Z")

</div>

Just when I think I’m asking the right question :huh:

Now I’m beginning to wonder if any of the above makes sense… or if I do for that matter 🙂

Clarity anyone?

Should I shuck it and try something else?

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [March 21, 2006, 6:40am UTC](https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707/6 "2006-03-21T06:40:03Z")

</div>

You can use the asfunction protocol to call a function, for example you would use this in the XML:

```auto
<a href='asfunction:loadMovieProxy,0506.swf'>press me</a>

```

And have this function in the same time line as your text field:

```auto
function loadMovieProxy(target:String):Void {
 trace(target);
 pathTo.empty.loadMovie(target);
}

```

[FONT=Courier New]asfunction:function:Function,parameter:String[/FONT]  
See the help file for more info. Note that you can only pass one parameter to the function called, you can overcome this by using a delimiter in the string and splitting it in the function:

```auto
<a href='asfunction:asfunctionTest,param1,param2,param3'>press me</a>

```

```auto
function asfunctionTest():Void {
	var params:Array = arguments[0].split(",");
	for (var i in params) {
		trace(params*);
	}
}

```

Hope this helps :hoser:

---

<div class="post-metadata">

**Author:** ![quandary23](https://avatars.discourse-cdn.com/v4/letter/q/f04885/32.png) [@quandary23](https://forum.kirupa.com/u/quandary23)\
**Post date:** [March 21, 2006, 7:31am UTC](https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707/7 "2006-03-21T07:31:44Z")

</div>

So using a delimiter will allow for the multiple links in the txt file to link to different swfs (ie. the different galleries).

Whereas the first asfunction will call the same function for each link in the file - loading only 0506.swf for each.

Am I understanding that right, albeit in rudimentary laymanspeak? :block:

Thanks for the directional point toward clarity surrounding this issue. I’m out of my league here, but glad to be learning by fire among good hands and minds.

I’ll start digging into the help files less blindly now thanks to you Canadian.  
:book:

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [March 21, 2006, 8:02am UTC](https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707/8 "2006-03-21T08:02:01Z")

</div>

No, using the delimiter is only if you want to pass multiple parameters to a single function call and shouldn’t be necessary to use in your case. Something like this is all you need to do:

```auto
You can <a href='asfunction:loadMovieProxy,0506.swf'>press me</a> to load 0506.swf or <a href='asfunction:loadMovieProxy,0406.swf'>me</a> to load 0406.swf.

```

```auto
function loadMovieProxy(target:String):Void {
 trace(target);
 pathTo.empty.loadMovie(target);
}

```

If you press _press me_, it will load 0506.swf whereas pressing the second _me_, you will load 0406.swf 🙂

---

<div class="post-metadata">

**Author:** ![quandary23](https://avatars.discourse-cdn.com/v4/letter/q/f04885/32.png) [@quandary23](https://forum.kirupa.com/u/quandary23)\
**Post date:** [March 21, 2006, 9:46am UTC](https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707/9 "2006-03-21T09:46:17Z")

</div>

That is making more and more sense. Thanks immensely for the light-shedding.

I have a quick question though. I just tried it in multiple iterations of refering to add the \_root (where 0406.swf and the empty mc are), in both the html and the AS in as many variations as I can think of… with no luck.

Would you mind showing me where to add it?

Thanks C!

---

<div class="post-metadata">

**Author:** ![quandary23](https://avatars.discourse-cdn.com/v4/letter/q/f04885/32.png) [@quandary23](https://forum.kirupa.com/u/quandary23)\
**Post date:** [March 21, 2006, 11:58am UTC](https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707/10 "2006-03-21T11:58:56Z")

</div>

here are the source files I’ ve been using to test with.

[http://www.co-laboratory.com/rb/kirupa/test.zip](http://www.co-laboratory.com/rb/kirupa/test.zip)

They mimick the structure of the working site since it’s too fat to post.

The trace lists 0406.swf and 0506.swf, but I can’t get them to actually show up and load into the empty mc on \_root.

?  
:hangover:

---

<div class="post-metadata">

**Author:** ![quandary23](https://avatars.discourse-cdn.com/v4/letter/q/f04885/32.png) [@quandary23](https://forum.kirupa.com/u/quandary23)\
**Post date:** [March 22, 2006, 2:40am UTC](https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707/11 "2006-03-22T02:40:13Z")

</div>

Anyone?

---

<div class="post-metadata">

**Author:** ![quandary23](https://avatars.discourse-cdn.com/v4/letter/q/f04885/32.png) [@quandary23](https://forum.kirupa.com/u/quandary23)\
**Post date:** [March 22, 2006, 9:52am UTC](https://forum.kirupa.com/t/xml-as-is-this-even-possible/182707/12 "2006-03-22T09:52:29Z")

</div>

Found the answer elsewhere:  
[http://www.thecodebehind.com/code/flash/actionscript/loading-external-swfs-from-an-external.aspx](http://www.thecodebehind.com/code/flash/actionscript/loading-external-swfs-from-an-external.aspx)

Thanks to Canadian for his help in clearing up the concept, allowing my googling to bear results!
