A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: Accordian AS explanation

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

    Smile Accordian AS explanation

    Hey all!

    I downloaded this .fla file off the net which is basically an accordian with some nifty AS.

    I wanted to know how the AS exactly worked. I get some part of it, but mostly it goes over my head. I modified AS and the movieclips in the file for my use, and its mainly done now. But I still want to understand the logic behind the whole script!

    I am not good at all when it comes to scripting. I can only use some very basic actions like gotoandstop and loadmovie etc effectively. But I want to really know how it works, and would really appreciate if someone could break this "code" down for me. Exactly what the AS tells Flash to do in each line. Would really appreciate it! Its Flash CS4 file, you can download it and view it too =) I am attaching the AS2 below as well. Thanks a lot!!

    stop();
    speed = 10;
    initial_width = 75;
    target_width = 450;
    sp = rect1._x;
    this.createEmptyMovieClip("emptymc", 0);
    emptymc.onEnterFrame = function() {
    for (i=1; i<=6; i++) {
    if (_root.hit.hitTest(_root._xmouse, _root._ymouse, true)) {
    if (_root["rect"+i].hitTest(_root._xmouse, _root._ymouse, true)) {
    new_x = (_root.sp-(75*(i-1)))-rect1._x;
    rect1._x += new_x/speed;
    n_width = target_width-_root["rect"+i]._width;
    _root["rect"+i]._width += n_width/speed;
    } else {
    n_width2 = initial_width-_root["rect"+i]._width;
    _root["rect"+i]._width += n_width2/speed;
    }
    } else {
    new_x = _root.sp-rect1._x;
    rect1._x += new_x/(speed+50);
    n_width2 = initial_width-_root["rect"+i]._width;
    _root["rect"+i]._width += n_width2/(speed-1);
    }
    _root["rect"+(i+1)]._x = _root["rect"+i]._x+_root["rect"+i]._width;
    _root["movie"+i]._x = _root["rect"+i]._x-1;
    }
    };
    Attached Files Attached Files
    Last edited by Buraaq; 11-14-2010 at 01:09 PM. Reason: Forgot to copy-paste the script =)

Tags for this Thread

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