XML/AS - Is this even possible?

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:


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

or what have you…

That should work, yes.

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!

:slight_smile:

Thank you!

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 :slight_smile:

Clarity anyone?

Should I shuck it and try something else?

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

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

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

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:

<a href='asfunction:asfunctionTest,param1,param2,param3'>press me</a>
function asfunctionTest():Void {
	var params:Array = arguments[0].split(",");
	for (var i in params) {
		trace(params*);
	}
}

Hope this helps :hoser:

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:

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:

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.
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 :slight_smile:

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!

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

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:

Anyone?

Found the answer elsewhere:
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!