dcsimg
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: can anyone help me?

  1. #1
    Member
    Join Date
    May 2002
    Posts
    47

    can anyone help me?

    i was wondering if it was possible to do the following scenario.

    1. there's a movie clip with a input text box, having an instance name called "active". the text box in "active" can be selected.

    2. if you click on a toggle button, the text box in "active" becomes unselectable and becomes drag and drop.

    3. if the toggle button is clicked again, then the "active" movie clip is no longer able to be dragged and dropped and the text box in "active" becomes selectable again.

    i've got #1 and #2 working, but i can't get #3 to work. once i click on the toggle button, "active" always has the capacity to be dragged an dropped.

    here's the code i'm using on a frame for the "active" movie

    function activateDrag() {
    active.myText_txt.selectable = false;
    activate = true;
    if (activate) {
    active.onPress = function() {
    this.startDrag();
    getName = this._name;
    };
    active.onRelease = function() {
    this.stopDrag();
    };
    }
    }

    function deactiveDrag() {
    activate = false;
    active.myText_txt.selectable = true;
    }

    the toggle button will either call activateDrag() or deactiveDrag() depending on what state it's in. and i know it's being called properly.

    i think there's something wrong with my activateDrag function because it doesn't seem to be able to stop the movie clip's ability to be drag and dropped.

    any ideas?
    Last edited by thunder127; 03-03-2004 at 07:21 PM.

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    I don't have your doc so I'm not postive but heres a couple things you could try.

    In your activateDrag() function you set activate to true and on the next line you check if it's true. Your if will always come out true so you dont need it, just the commmands in it. Also, the activate variable is set locally to the function so when you set it to false in the other function you are actually creating another variable local to that function equal to false. It's better to set it as a property of the active movie clip in both functions.
    Code:
    function activateDrag() {
    active.myText_txt.selectable = false;
    active.activate = true; //creates a property for the instance 'action' called activate.
    active.onPress = function() {
    this.startDrag();
    getName = this._name;
    }
    active.onRelease = function() {
    this.stopDrag();
    }
    }
    That way your other function can change the exact same variable. Also, when a movie clip has mouse functions it loses other functionality such as selectable type. So in the deactivate function delete the onPress and onRelease created by activateDrag function
    Code:
    function deactiveDrag() { 
    active.activate = false;  //changes the value of the active's activate property
    delete active.onPress;
    delete active.onRelease;
    active.myText_txt.selectable = true;
    }
    Last edited by jAQUAN; 03-03-2004 at 07:46 PM.

  3. #3
    Member
    Join Date
    May 2002
    Posts
    47
    thanks for the help! it worked great
    i didn't know you could delete functions like that.

    so i guess there's no point in using the active.activate= true line since it'll always be true in that function?

  4. #4
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    no, you will need that line to change it back to true since the other function will be changing it to false. You just dont need the if command that checks on it.

  5. #5
    Member
    Join Date
    May 2002
    Posts
    47
    okay. thanks a lot for your help!

    you seem to know a lot about actionscript, so perhaps you could answer another question of mine :0

    is there a way to figure out all of the movie instances on the stage at any given time?

  6. #6
    free-webmaster-resource.com deamothul's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    1,475
    Originally posted by thunder127

    is there a way to figure out all of the movie instances on the stage at any given time?
    You can check all the clips you have and their paths at runtime when u run your swf ( ctrl+enter) and goto DEBUG>list objects

  7. #7
    Member
    Join Date
    May 2002
    Posts
    47
    i was aware that you can use the debugging mode to see open instances.. sorry for my lack of clarity.

    i wanted to know if there was actionscript that did that, so i could determine which instances were on the stage at any given time and do something with them from that.

  8. #8
    free-webmaster-resource.com deamothul's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    1,475
    something like:

    Code:
    for ( var i in _root){
    	if(_root[i] instanceof MovieClip){
    	   trace(_root[i]._name)
    	}
    }

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