stop(); speed = 10; initial_width = 75; target_width = 450; sp = rect1._x; this.createemptymovieclip("emptymc", 0); emptymc.onenterframe = function() { (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; } }; thanks all, understand ! try translate as3 , seems good. there're still minor bugs, try find , sorry inconvenience. :(
again, thank all. :).
my code imcomplete, can you. need put movie clips called "rect" in array called "rects" , movie clips called movie in array called movies.
variables , movie clips prefix "_root" must declared global.
stop(); speed = 10; initial_width = 75; target_width = 450; sp = rect1._x; emptymc = new movieclip(); emptymc.addeventlistener (event.enter_frame , onenterframe); function onenterframe (e:event):void{ (var i:int=1; i<=6; i++) { if (hit.hittestpoint(stage.mousex, stage.mousey,true)) { if (rect.hittestpoint(stage.mousex, stage.mousey, true)) { new_x = (sp-(75*(i-1)))-rect1._x; rect1.x += new_x/speed; n_width = target_width-rects[i].width; rects[i]._width += n_width/speed; } else { n_width2 = initial_width-rects[i].width; rects[i].width += n_width2/speed; } } else { new_x =sp-rect1.x; rect1._x += new_x/(speed+50); n_width2 = initial_width-rects[i].width; rects[i].width += n_width2/(speed-1); } rects[(i+1)].x = rects[i].x+rects[i].width; movies[i].x = rects[i].x-1; } }
Comments
Post a Comment