A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Accessing variable in attached clips

  1. #1
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427

    Accessing variable in attached clips

    I am attaching clips from the library based on which button the user selects. The clip is attached (and instantiated as "detail") to an empty movie clip (with instance name "slot") that's created in a container ("popUp") when the button is pressed. All the possibilities for the attached clip, detail, have a variable category. It seems that popUp.slot.detail.category, should be the path to this value, but it returns undefined. Any ideas how to access this.

    Another strange thing. As a possible work around, instead of assigning the variable locally in the attached clip and finding it there, I thought i'd assign it on the _root from inside the clip. Thus the variable isn't given a value until the clip is loaded and the first frame runs. Then i trace the variable _root.category from the clip and i get the value. But in the function that's doing everything, it returns undefined. Here's the function set up:

    On Button Pres:
    create movie clip
    attach movie clip (variable should be set at this time right?)
    call display function

    Display Function:
    make container visible
    trace _root.category (returns undefined)


    Any insight here would be very much appreciated. Thanks for thinking about it.

  2. #2
    Senior Member Dricciotti's Avatar
    Join Date
    Aug 2002
    Posts
    2,988
    Is "detail" the instance name of a clip or the identifier for the clip while it is in the library? If it is just the identifier, you can access it with "popUP.slot.category".

  3. #3
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    Thanks for the reply Dricciotti. "detail" is the instance name assigned in the attachMovie() call. Different user inputs will lead to different clips with different identifiers, but all of them will have the category variable assigned and wall will be attached using the same instance name. So wouldn't the path be popUp.slot.detail.category? since "detail" is now a specific instance of a clip that is attached to the slot clip which sits in popUp.

    Thanks again.

  4. #4
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    Upon further testing it seems to be the timing, not the path itself that is problematic. If i try to reference the variable defined in the attached clip inside the function that's attaching it, or even within a function called by the function attaching it...Nothing. However when I set up a simple keylistener function to trace the variable on key press, it shows just fine. Any idea why it wouldn't be available to root level functions right away?

  5. #5
    Senior Member Dricciotti's Avatar
    Join Date
    Aug 2002
    Posts
    2,988
    I use the following code a lot to check the path of a variable or movie clip. Put it inside the movieclip you are having problems with:
    code:
    node = this;
    while(this._name != _root._name)
    {
    trace([node._name]);
    node = node._parent;
    }


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