Flash Help Needed

  • Started
  • Last post
  • 5 Responses
  • propa

    Can you use a variable to target a property of a movie clip? What I wish to do is have my functions on the main timeline, and when I invoke my functions I will supply parameters. These parameters will tell the function how to find the _y property for instance. I.e. (_root.newsDisplay.scrollBar._y... What would be the best is if I can make the newDisplay instance name a variable as well. That way everything that I need scrolled will use the one function and I can supply the instance name as a parameter of the function.

    Thanks in advance.

  • preston0

    if you are trying to target say the alpha of movieclip1... you'd do this:

    mcname = "movieclip1";
    _root[mcname]._alpha = 100;

    I think this works with properties too ie:

    mcprop = "_alpha";
    _root.movieclip1[mcprop] = 100;

    I've done dynamically defined instance names before, but never properties...

    anyways, this stuff is on page 181 of the Flash MX manual.

  • propa0

    Thanks Preston,

    Its not quite working but I think you pointed me on the right “path”. I'll check my studio Mx book for dynamically named instances.

    This is the error I get when I try this right now.

    Scene=Main, Layer=Advance, Frame=1: Line 23: Expected a field name after '.' operator.

    _root.[clipName].scrollBar.
    _height = barscrollresize;

  • o0o0

    oh! I see the proplem propa, you don't need that dot after _root

    _root._y is a property, but the bracket syntax is _root["_y"]

    I didn't know you could access the properties that way, that's cool... but the syntax thing is the reason for that error...

  • preston0

    yeah, the idea is to use either the "array access operators" or "dot access operators" (dont need both)... but yeah, I'm curious to see if that works out for you.... mind posting the working line of code propa?

  • propa0

    I’m still playing around with it but thanks for pointing me in the right direction. You have to use a string to define the name or property; that is what I was having trouble understanding. Thanks, very much. I actually got more help here than I got on flask kit. The studio Mx manual is literally useless; fortunately I purchased the Action script definitive guide and looked up dynamic references.

    I’ll try to keep you updated. Thanks very much.