A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: MovieClip names in variables

  1. #1
    Junior Member
    Join Date
    Aug 2004
    Location
    Mansfield, TX
    Posts
    2

    MovieClip names in variables

    Flash MX 2004 Professional

    GOAL:

    I'm loading a list of filenames from an external file into a variable, then splitting the variable into an array (fileArray) with one filename in each array element.

    For each element in the array (fileArray[n]), I need to duplicate a movieClip and load an external JPG (from the array of filenames) into the new movieClip.

    PROBLEM:

    This is where things start to break. On each iteration, the dynamically generated instance name (jpg1, jpg2, etc.) of the newly duplicated movieClip is stored in a variable (clipName).

    I have no problems setting properties on the new movieClip using the variable (clipName._x = 120) instead of the literal movieClip name (jpg1, jpg2, etc.).

    However, I cannot assign variables within the new movieClip (clipName.varName = fileArray[n]) or load a JPG into the new movieClip using the variable (clipName.LoadMovie(fileArray[n]) OR loadMovie(fileArray[n],clipName))

    SOLUTION:

    Any guidance you fine folks can give me on how to solve this problem would be greatly appreciated. I've been tearing my hair out and am now completely bald.

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    Since clipName is a variable referring to the name of the actual movieclip, you'll need to use either eval() or array-style notation (I prefer the latter).

    Assuming clipName refers to a movieclip attached to _root, you would use:

    _root[clipName]._x = ??;

  3. #3
    Junior Member
    Join Date
    Aug 2004
    Location
    Mansfield, TX
    Posts
    2
    Hey, that worked!

    Too bad the online help is so vague about that usage.

    Is there someplace in the online documentation that I might have found this information? I searched and searched to no avail.

    Thank you so much.

  4. #4
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    It's called associative array syntax...

    http://www.flashkit.com/tutorials/In...-182/more3.php

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