A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: and && ??fmx04

  1. #1
    Member
    Join Date
    Jan 2004
    Posts
    87

    and && ??fmx04

    Hi
    I have this script:
    code:

    on (release) {
    with (this._parent.mc_wv) {
    gotoAndStop(1);}
    }


    and i have many mcs in the same location that i want to do the same thing
    can i use and "&&" (and) function?
    I tryed this but not worked:
    code:

    on (release) {
    with (this._parent.mc_wv) && (this._parent.mc_va) {
    gotoAndStop(1);}
    }


    Thank you very much
    Cya

  2. #2
    FK Slacker
    Join Date
    Jun 2000
    Location
    vancouver
    Posts
    3,208
    The AND operator (&&) doesn't work like that, it is used to evaluate multiple conditions, ie:
    code:

    var first="homer";
    var last="simpson";
    if(first=="homer" && last=="simpson"){
    trace("I like donuts");
    }
    else{
    trace("D'oh!");
    }



    To target multiple movie clips, store the clip names in an array, then loop through the array:

    code:

    on (release) {
    var mcList=["mc_wv","mc_va"];
    for(var mc in mcList){
    this._parent[mcList[mc]].gotoAndStop(1);
    }
    }



    HTH,

    K.

  3. #3
    Member
    Join Date
    Jan 2004
    Posts
    87
    Thank you very muck, i understand now

  4. #4
    Member
    Join Date
    Jan 2004
    Posts
    87
    I'm trying to aks you guys something i'm not sure fi u will understand me.
    I have a map with 60 states, every state is a mc with 3 frames one for up and
    the other for down state the 3'rd frame is a action
    gotoAndStop(1); action. and a button inside that has the next script:
    code:

    on (release) {
    with(this)
    nextFrame();
    }
    on (release) {
    with (this._parent.mc_1) {
    gotoAndStop(1);}
    with (this._parent.mc_2) {
    gotoAndStop(1);}
    .
    .
    .
    with (this._parent.mc_60) {
    gotoAndStop(1);}
    }


    this script alows only one state to be selected
    and i have to put this script for every button

    I could use this script
    code:

    on (release) {
    var mcList=["mc_1",...."mc_60"];
    for(var mc in mcList){
    this._parent[mcList[mc]].gotoAndStop(1);
    }
    }


    but then all the mc will go to frame 1 including the one is pressed.
    I dont have any idea who to make the mcs go to frame one and the mc is pressed to go at frame 2.
    If someone have any idea, i will be very happy.

    Thank you very much

    P.S
    If i have huge code the SWF will be bigger ?
    Last edited by maydays; 09-23-2004 at 03:57 PM.

  5. #5
    Re Member websam's Avatar
    Join Date
    Jul 2000
    Location
    Australia (VIC)
    Posts
    660
    Option A: (not a good option as for performance wise, for loop is not a good option);

    code:

    on (release) {
    var mcList=["mc_1",...."mc_60"];
    for(var mc in mcList){
    this._parent[mcList[mc]].gotoAndStop(1);
    }
    this._parent.gotoAndPlay(2);
    // the first lot tells all mc to reset.
    // added red line tells teh caller mc to play.
    }



    In fact, you you have naming convention like the one you didi in an array "mc_1....60". You don;t need array to hold mc name at all.

    on (release) {
    for(i=1;i<=60;i++){
    this._parent["mc_"+i].gotoAndStop(1);
    }
    this._parent.gotoAndPlay(2);
    // the first lot tells all mc to reset.
    // added red line tells teh caller mc to play.
    }
    [/AS]


    Option B: (having one variable to hold clicked item name. and reset it when other mc is clicked)

    code:

    on (release) {
    // if not the first click, reset previous clicked MC
    if (_root.clickedMC!=""){
    _parent[_root.clickedMC].gotoAndStop(1);
    }
    // play clicked mc
    this.gotoAndPlay(2);
    // update clickedMC variable
    _root.clickedMC=this._name;
    }



    See attached sample FLA to get better options
    Attached Files Attached Files

  6. #6
    Member
    Join Date
    Jan 2004
    Posts
    87
    THank you very much, i think i got it now
    Last edited by maydays; 09-24-2004 at 11:06 AM.

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