dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Tough One...

  1. #1
    Junior Member
    Join Date
    Mar 2001
    Posts
    27

    Wink

    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'?


  2. #2
    Junior Member
    Join Date
    Apr 2000
    Posts
    16
    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.


  3. #3
    Junior Member
    Join Date
    Mar 2001
    Posts
    27
    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?

  4. #4
    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:

    Code:
    _root.gotoAndPlay("idle");
    But neither of these will:

    Code:
    gotoAndPlay("idle");
    
    or
    
    _parent.gotoAndPlay("idle");
    The XML object was created on the root timeline, frame 1.

  5. #5
    Junior Member
    Join Date
    Apr 2001
    Posts
    23
    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?
    Code:
    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?

  6. #6
    Junior Member
    Join Date
    Mar 2001
    Posts
    27
    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();
    }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center