A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [F8] simple splice problem

  1. #1
    Member
    Join Date
    Dec 2005
    Posts
    30

    [F8] simple splice problem

    hi
    inside my mc i have a couple of lines of code to get the mc's name and then i want to splice out of that the number so it can be used for something else but i keep getting undefined in my output box. can anyone help me please!?

    below is the code i've got so far.
    Code:
    mcName = this._name
    
    // mcName = drag1_mc
    
    mcNum = mcName.splice(4,1);
    cheers chris

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    what exactly r u trying to do ... what r u using the number for ? you tryign to figure out which button was pressed?
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    Member
    Join Date
    Dec 2005
    Posts
    30
    yeah when they push a button it will then pass the number to a function.

    Code:
    mcName = this._name
    
    // mcName = drag1_mc     -- so you know the name
    
    mcNum = mcName.splice(4,1);
    
    // for now i am just picking it up on rollover and tracing it out but will be changing
    
    this.btn.onRollOver = function(){
     trace("mcNum = "+mcNum)
    }

  4. #4
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    rather than using string manipulation to see which button is being pressed ..assign the movieclips a dynamic variable just before you assign it an onRelease event e.g

    suppose you have buttons mc1, mc2, mc3 .....

    Code:
    for(var i:Number=1; i<=3; i++){
    
      this["mc"+i].id = i;
      
      this["mc"+i].onRelease = function():Void{
    
       trace("you just pressed button number " + this.id);
      }
    
    
    }
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  5. #5
    Member
    Join Date
    Dec 2005
    Posts
    30
    hi. thank you for your help. i've managed to fix the problem in the mean time, stupid me was using splice and not slice! 1 bloody letter was the problem.
    Cheers anyways

  6. #6
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    np yw
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

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