A Flash Developer Resource Site

+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Senior Member
    Join Date
    Aug 2004
    Location
    UK, near a garage
    Posts
    211

    change colour on stopDrag();?

    I am using the code below which I would like to include the possibility of changing the colour of the text inside a button, is that even possible?

    code:

    for (mc in this) {
    this[mc].onPress = startDrag;
    this[mc].onRelease = stopDrag;
    }

    thisLevel = this
    for (i = 0; i<= 3; i++) {
    thisLevel ["circle"+i].onPress = stopDrag;
    this["circle"+i].onRelease = stopDrag;
    }


  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    not possible with button timelines
    you need to use movieclips and the textColor property

    for example, the first code, applied to a button instance name - btn -- fails
    the second, applied to a movieclip instance name - clip -- works
    txt is the instance name of a dynamic textfield
    Code:
    btn.onRollOver = function(){
    btn.txt.textColor = 0x00FF00;
    }
    
    clip.onRollOver = function(){
    clip.txt.textColor = 0x00FF00;
    }

  3. #3
    Senior Member
    Join Date
    Aug 2004
    Location
    UK, near a garage
    Posts
    211
    Quote Originally Posted by a_modified_dog
    not possible with button timelines
    you need to use movieclips and the textColor property

    for example, the first code, applied to a button instance name - btn -- fails
    the second, applied to a movieclip instance name - clip -- works
    txt is the instance name of a dynamic textfield
    Code:
    btn.onRollOver = function(){
    btn.txt.textColor = 0x00FF00;
    }
    
    clip.onRollOver = function(){
    clip.txt.textColor = 0x00FF00;
    }
    Thank you for helping a_modified_dog!

    So you mean creating Mcs instead of buttons? The code your using does not seem to enable the clips to be dragged though as my code above or am I missing something? I was hoping to create an application where clip_mcs are dropped onto an area, say, area_mc and when they are dropped they change colour.

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    i have attached a simple fla

    note how the movieclip has 3 frame labels
    _up, _over, _down

    these labels simulate a button rollOver and press event
    without additional coding
    Last edited by a_modified_dog; 08-17-2007 at 06:33 PM.

  5. #5
    Senior Member
    Join Date
    Aug 2004
    Location
    UK, near a garage
    Posts
    211

    Spot on!

    Thank you a_modified_dog it works brilliantly! As I have 20-odd clips on the stage is there a way to have the code apply to all of them without having to write this code 20-odd times?

    I really appreciate your help, cheers for this

  6. #6
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    use a numbered sequence for the clip instance names - clip1 clip2 clip3....
    you can cycle thro' the numbers in a loop to set the events

    simple file with 5 clips attached
    Last edited by a_modified_dog; 08-17-2007 at 06:33 PM.

  7. #7
    Senior Member
    Join Date
    Aug 2004
    Location
    UK, near a garage
    Posts
    211
    Thank you for persisting with me and for solving my problem(s) (yet again!!) a_modified_dog!!!

    Gabriel

  8. #8
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    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