PDA

Click to See Complete Forum and Search --> : Tough One...



IO_MCollins
04-24-2001, 07:03 PM
Hello all,

I'm running into a problem with an xml operation and I hoped you smart folks might help me solve it.

The following code is attached to a movie clip:

//Objective - try to get the proc_reply callback function
//to populate 'anArray' without using absolute target paths.

onClipEvent(load){

var anArray;
xml_out = new XML();

reply = new XML();
reply.onload = proc_reply;
xml_out.sendAndLoad("http://TheScriptUrl", reply);

function proc_reply () {

anArray = this.firstChild.childNodes();
}
}

At present, 'anArray' is out of scope of the call-back function and I cant use a static absolute path within the function to get to this variable. I.e. the movie clip does not have a static name so I cannot reference it.

Any suggestions on how to populate 'anArray'?

TeamDigital
04-26-2001, 02:33 AM
Which movie clip are you trying to reference to?

In other words: When do you choose to reference to MyClip[x]?

There are probably thousands of combinations otherwise.

IO_MCollins
04-26-2001, 04:04 PM
Hey,

Thanks for the reply!

I'm trying to reference the clip without using an absolute path.

I guess my problem is that proc_reply() is called at the root level instead of at the local level, even though it is defined within that movie clip. I should be able to say:

function proc_reply(){

this.anArray = [1,2,3,4,5...];

}

Unfortunately 'anArray' cannot be called unless given the full path to the movie clip. For instance:

function proc_reply(){

_root.thisclip.thatclip.theotherclip.anArray = [1,2,3,4,5...];

}

What I want to know is... is there any way around that?

mikebrittain
05-01-2001, 03:11 PM
I think I'm having a similar problem.

I want to use an onLoad handler for the XML object that I've created that will jump the movie to a new frame (label).

If I use this line, it will work:



_root.gotoAndPlay("idle");


But neither of these will:



gotoAndPlay("idle");

or

_parent.gotoAndPlay("idle");


The XML object was created on the root timeline, frame 1.

hal(var)
05-01-2001, 08:22 PM
Do you get the same results in the standalone player and in the browser?
When I assign a function to handle .onXML which is not at the root level of the movie I have problems, because in the authoring eviroment an standalone player the function executes in the contexe of _root no mater where it is located, but in the plugin and activeX it executes in the context of the MovieClip that function is defined in.

but given the issue, can the clip update a pointer to itself at the root level?


reply = new XML();
reply.onload = proc_reply;
_root.targetclip = "path to self";
xml_out.sendAndLoad("http://TheScriptUrl", reply);

function proc_reply () {

eval(_root.targetclip).anArray = this.firstChild.childNodes();
}

this would not work out if there multiple clips that may call this at the same time. and the clip needs to knows the path to itself, (e.g. _root.dynamic_MC99.loadXML_MC).

Is there a way for a clip to find out it's path?

IO_MCollins
05-01-2001, 09:28 PM
Thanks for relpies!

I have created a solution similar to yours hal. This enables you to have multiple access and path to self.

onClipEvent(load){

var anArray;
xml_out = new XML();

reply = new XML();
reply.onload = proc_reply;
//Places a reference to parent movie clip in global array
_root.queue.push(_parent);

xml_out.sendAndLoad("http://TheScriptUrl", reply);

function proc_reply () {
//returns the first clip in queue
target = _root.queue.shift;
target.anArray = this.firstChild.childNodes();
}
}