A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Dynamically assign _visibility variable from XML to button..

  1. #1
    Junior Member
    Join Date
    Jun 2001
    Posts
    13

    Dynamically assign _visibility variable from XML to button..

    Thank for reading this. Basically I am trying to dynamically assign the _visibility property of a button. The property will be loaded from XML. So far this is how I am approaching it. link2 is the instance name of the button and _root.visible2 is he variable that I have brought in from the XML in frame one. It will be either true or false depending on what the XML contains. Is there something wrong with my syntax? Or am I approaching this the wrong way?:

    Code:
    setProperty(_root.link2, _visible, _root.visible2);
    
    (as I see it when flash has all the variables loaded in it should be this:
    setProperty(_root.link2, _visible, true);
    I am trying to set my flash movie up so I can turn off buttons in the XML if I want to. I already checked my XML and it's loading variables in for everything else no problem so it's not a connection problem.

    Thanks for any help offered.

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    you dont need setproperty. just dot syntax is plenty.
    Code:
    link2._visible=visible2;
    also note that the string "false" resolves to true. e.g.
    Code:
    var a="false";
    someclip._visible=a;
    //someclip will be visible
    var b=false;
    someclip._visible=b;
    //someclip will be hiden;

  3. #3
    Junior Member
    Join Date
    Jun 2001
    Posts
    13
    OK... I think I am getting there. Thanks for the quick response. Now. One question. I am trying to determine the visibility of a button. I have tried this two ways.. I tried dropping the button into a movie clip and I have also tried setting the _visible property directly on the button. Both are loading in the variable from XML. The button goes to a frame lable that is also a variable pulled in from xml. ( _root.shorttitle6)

    When I put the button in a movie clip I can set the visibility no problem from the XML. but then the button no longer functions even though I am setting the path in the button to control the main timline:
    Code:
    on (release, rollOver) 
    gotoAndStop("_root.shorttitle6");
    }{
    I also tried:
    Code:
    on (release, rollOver) 
    gotoAndStop(_root.shorttitle6);
    }{
    This code works when the button is in root and not embedded in a movie clip.

    The following code that you helped me with works when I use it to handle the movie clip but not the button. (can visibility even be set directly on a button?)
    Code:
    link6._visible=visible6;
    So the real question is which way would be better to do it. I can upload my fla if it would help. Should I put the button in an mc and set the visiblity of the mc? (if so how do I get the rollover action to make the main timelinego to a dynamic frame lable) OR Should I set the visibility directly on a button that sits in root. (if so how do I set the _visible property on it?) Thanks again.. this is kicking my butt.

  4. #4
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    dont use buttons at all. there's nothing a button can do that a movieclip can't, but the reverse isnt true.

    try to keep all your script in the frame actions, rather than attached to a particular object.

    events on movieclips are written like so:
    Code:
    movieclipinstancename.onPress=function(){
    //statements
    }
    onRollOver,onRollOut,onRelease,onMouseMove,onMouse Up,onMouseDown,onKeyUp,onKeyDown, onEnterFrame are used similiarly. when you're inside the curlies {} and you say "this" you're talking about movieclipinstancename. when outside the curlies and you say "this" you're talking about the timeline the frame is in, commonly _root.

  5. #5
    Junior Member
    Join Date
    Jun 2001
    Posts
    13
    That clears a lot up. Just wanted to say thanks. I think I get it now.

  6. #6
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    you're welcome

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