A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: variable not working right

  1. #1
    Senior Member
    Join Date
    Jul 2010
    Posts
    111

    variable not working right

    Hello, I am trying to write a variable in the middle of a command, like:

    (in root, myvariable=12)

    in another movie clip:

    var movieclipnumber = _root.myvariable
    _level2.this["othermovie"+movieclipnumber].gotoAndStop(5)

    but flash keeps giving me the error:

    "Expected a field name after '.' operator."

    I am trying to get the logic to think:

    _level2.othermovie12.gotoAndStop(5)

    Is the syntax wrong? I think it's trying to consider "_root" in the variable "movieclip" as an actual path, where I just want it to be a reference for the variable "myMC", which happens to be in "_root". (I hope that wasnt too confusing!)

    Thank you!

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    Perhaps you can post your fla, or more of your code here.

  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    _level2["othermovie" + movieclipnumber].gotoAndStop(5);

    it would still help to see your fla

  4. #4
    Senior Member
    Join Date
    Jul 2010
    Posts
    111
    Thanks fruitbeard, that was exactly it! I wonder why you wouldnt use a dot after _level2, but who am I to question. Thanks again

  5. #5
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    276
    I would think of it like, _level2 as being the MovieClip or location of whatever is between the square brackets. So, when you used "_level2.this[stuff]" it was using 2 locations, _level2 and this (relative to its current location).
    Hope that gives you some insight.

  6. #6
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    921
    "this" just does not ever go after "." because it is keyword - hence the error:

    "Expected a field name after '.' operator."

    A field name. Not keyword.
    who is this? a word of friendly advice: FFS stop using AS2

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