dcsimg
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Use the path to a MC as a String?

  1. #1
    Member
    Join Date
    Oct 2005
    Posts
    56

    Use the path to a MC as a String?

    Was wondering if you could help me here:

    I've got the following code on a MC:

    code:

    trace(this); //outputs "_root.box1.box2.box3" <-- this is what i would like to use
    trace(typeof(this)); //outputs "movieclip"
    trace(this.toString); //outputs "[object Object]"



    How can I use what the trace function outputs ("_root.box1.box2.box3") as a variable. If trace returned what it was outputting, that would be good, but alas. MovieClip.toString() fails too.

    Only way i can see of doing this to use the "MovieClip._name" var, then go up to "MovieClip._parent" MC and get its "_name" . And then keep on going up, using _parent, adding the _name.
    Help build a Flash Online Multi Player RPG:

    trac link

    Will be Open Source
    BETA should be out end of year (hopefully )

  2. #2
    dubba you tee eff steven_h_2000's Avatar
    Join Date
    Oct 2000
    Location
    Columbus, Ohio
    Posts
    137
    Well It's dificult to answer your question because I don't see what you are trying to accomplish, please elaborate?

  3. #3
    Member
    Join Date
    Oct 2005
    Posts
    56
    I would like to use the path to the movieclip as a string.
    When i trace a movieclip, it outputs the path to the movieclip. I would like to use this path as a variable.
    Help build a Flash Online Multi Player RPG:

    trac link

    Will be Open Source
    BETA should be out end of year (hopefully )

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    the correct syntax is .toString()


    gparis

  5. #5
    Member
    Join Date
    Oct 2005
    Posts
    56
    sorry gparis, that doesnt work, as i said in my original post, lol:

    code:

    trace(this.toString); //outputs "[object Object]"



    all i end up with is a string that contains "[object Object]".

    anyone else?
    Help build a Flash Online Multi Player RPG:

    trac link

    Will be Open Source
    BETA should be out end of year (hopefully )

  6. #6
    Member
    Join Date
    Oct 2005
    Posts
    56
    bump
    Help build a Flash Online Multi Player RPG:

    trac link

    Will be Open Source
    BETA should be out end of year (hopefully )

  7. #7
    Senior Member DrDoom's Avatar
    Join Date
    Apr 2006
    Posts
    144
    Code:
    var absLoc = String(this);
    trace(absLoc);

  8. #8
    Member
    Join Date
    Oct 2005
    Posts
    56
    yay it works
    Help build a Flash Online Multi Player RPG:

    trac link

    Will be Open Source
    BETA should be out end of year (hopefully )

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