as3拖动滚动条控制小球大小

import flash.geom.Rectangle;
var left:Number=mc.back.x;
var right:Number=mc.back.width-mc.drug.width;
stage.addEventListener(MouseEvent.MOUSE_UP,stopdrag);
mc.drug.addEventListener(MouseEvent.MOUSE_DOWN,startdrag);
function startdrag(event:MouseEvent):void {
var rect:Rectangle=new Rectangle(left,0,right,0);
mc.drug.startDrag(false,rect);
}
function stopdrag(event:MouseEvent):void {
//trace(event.currentTarget.x/292);
mc.drug.stopDrag();
ball.scaleY=ball.scaleX=mc.drug.x/292;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MATLAB_GUI控制小球加减速运动 btn.start.m function btn_start() global hball ipos delt isforward npos ispaused x y ispaused = false; while (1) set(hball, 'xdata', x(ipos), 'ydata', y(ipos)); drawnow; pause(delt); ipos = ipos-(-1)^isforward; if ipos==npos+1 ipos = 1; elseif ipos == 0 ipos = npos; end if ispaused break end end ball.m hfigure = figure('name', '控制小球运动 ver 1.0', 'menubar', 'none', 'numbertitle', 'off', 'position', [600 200 350 400], 'visible', 'off'); global hball ipos delt isforward npos ispaused x y haxes = axes('position', [0.25 0.45 0.5 0.5], 'visible', 'off'); axis equal t = 0:0.1:2*pi+0.1; x = sin(t); y = cos(t); line(x, y, 'linewidth', 2); set(0, 'defaultuicontrolbackgroundcolor', get(hfigure, 'color')); set(0, 'defaultuicontrolfontsize', 12); set(0, 'defaultuicontrolunits', 'points'); hball = line('xdata', 0, 'ydata', 1, 'marker', 'o', 'markerfacecolor', 'r', 'markersize', 15); npos = length(t); ipos = 1; delt = 0.01; ispaused = false; isforward = true; uicontrol('string', '开始', 'position', [30 50 50 20], 'callback', 'btn_start;'); uicontrol('string', '停止', 'position', [100 50 50 20], 'callback', 'ispaused = true;'); uicontrol('string', '换向', 'position', [170 50 50 20], 'callback', 'isforward = ~isforward;'); uicontrol('string', '退出', 'position', [100 20 50 20], 'callback', ['ispaused = true;', 'closereq;', ... 'clear delt hball ipos ispaused t y haxes hfigure isforward npos x;']); uicontrol('style', 'slider', 'value', 0.5, 'position', [40 90 190 15], 'callback', 'delt = get(gcbo, ''value'')/100+0.01;'); uicontrol('style', 'text', 'position', [40 110 190 20], 'fontsize', 12, 'string', 'speed'); % newicon = javax.swing.imageicon('1.png'); % figframe = get(hfigure, 'javaframe'); % figframe.setfigureicon(newicon); set(hfigure, 'visible', 'on');

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值