Flash游戏、Flash音乐、小游戏

加入收藏

设为主页

首页 | Flash游戏 | Flash音乐 | Flash动画 | 邻家女孩 | 动漫下载 | 小说 | 动漫资讯 | 免费博客

Flash游戏 | 动漫COSPLAY | 手机世界 | 游戏新闻 | IT业界 | 动漫设计 | 软硬件交流

首页>>动漫设计>>正文8ball里MovieClip类的新属性----scale9Grid

将woogood加入收藏夹 | 将woogood设置成为你电脑首页

搜索 SEARCH

    

8ball里MovieClip类的新属性----scale9Grid

作者:[] 来源:[] [2005-10-6 16:42:51] [对"8ball里MovieClip类的新属性----scale9Grid"发表评论]

最新文章

·隐藏卸载信息:跟入侵者玩躲猫猫
·网络新威胁 无线局域网入侵检测现
·宽带用户易被攻击 用户需注意七大
·如何查找和清除线程插入式木马程
·日志分析两部曲:充分利用日志保
·安全设置Windows组策略 有效阻止
·实现了!中文WinXP安装IE7 Beta1
·黑客破解Email账号常用的三种方法
·基础知识 XST攻击理论及手法讲解
·威胁同样巨大 基于Telnet协议的攻

推荐文章

·请教看电影多的人问题
·文字处理软件疑难问题求助,
·求助:Excel问题
·在线等...........
·大家都是怎样用摄像头的?发
·如何加启动程序?急
·midia player classic使用时
·关于IE,请大家帮助
·IE被改用兔子也没用啊??
·播放器问题,大家帮帮忙啊

  先看帮助文件,本人英语水平有限,看不懂请自行猜测或者对照原文。
scale9Grid (MovieClip.scale9Grid property)
public scale9Grid : Rectangle(矩形)
The rectangular region that defines the nine scaling regions for the movie clip. If set to null, the entire movie clip scales normally when any scale transformation is applied.
/*矩形区域为movie clip定义了9个缩放区域。如果这个值被设为null,则整个movie clip在任何缩放转换被应用时,将会被正常缩放。*/
When a scale9Grid property is defined for a movie clip, the movie clip is divided into a grid with nine regions, based on the scale9Grid rectangle, which defines the center region of the grid.
/*当一个movie clip被定义了一个scale9Grid,这个movie clip将在scale9Grid定义的中心区域栅格的基础上被分成一个包含9个区域的栅格。*/
  • The area in the upper-left corner outside the rectangle
  • The area above the rectangle
  • The area in the upper-right corner outside the rectangle
  • The area to the left of the rectangle
  • The area to the right of the rectangle
  • The area in the lower-left corner outside the rectangle
  • The area below the rectangle
  • The area in the lower-right corner outside the rectangle
  • //几个区域的位置。

    You can think of the eight regions outside of the center (defined by the rectangle) as being like a picture frame that has special rules applied to it when the movie clip is scaled.
    //你可以想想这处于中心周围的8个区域(矩形)就像一个图片帧当movie clip被缩放时被应用了特殊的规则。
    When the scale9Grid property is set and a movie clip is scaled, all text and child movie clips scale normally, regardless of which regions of the scale9 grid they are located in
    //当一个movie clip被设置了scale9Grid属性而且被缩放时,movie clip内部的所有text和子movie clip将同时被正常缩放,而无需关心那9个区域具体在哪里。----------------

    MovieClip类有了scale9Grid属性让我们可以做出更加自由、交互性更强的作品,活活。

    给scale9framedpicture.fla的AS加上注释,是翻译的。

    Stage.scaleMode = ’noScale’;
    /*
    9-slice scaling grids applied manually in movie clip symbol
    using constant border width. Scaling the image will cause
    the border within that picture to retain that width
    9-slice (9-薄片)手动缩放使用常量边界宽度栅格应用于movie clip symbol
    缩放图片将导致边界进入图片内部以保持边界宽度。
    */
    var border = picture_mc.scale9Grid.x; // start of scale9Grid x gives border size (since constant)
    //scale9Grid.x的属性赋予边界尺寸。
    // a "manipulate" point is now created to help in determining how the
    // image is being scaled when clicked. if scaling left, x will be -1
    // if scaling right, x will be +1 and if no x scaling is being done,
    // x will be 0; the same applies to y.
    //现在创建一个操作点帮助确定当图片被点击时是怎样被缩放的。
    //如果向左缩放,则x是-1,如果向右缩放,则x是+1,如果没有x轴缩放,则x是0
    //同样应用于Y轴。
    var manipulate = new flash.geom.Point(0,0);
    // two mouse variables (old & new) are used to store the
    // location of the mouse for scaling. These are compared
    // when scaling to see how far the mouse has moved
    //两个鼠标变量(old&new)将用来保存缩放时鼠标的位置
    //当进行缩放时它们用来比较,让我们知道鼠标移动了多远。
    //flash.geom.Point是Object类的子类,用于定义2维平面坐标,这里不作介绍。
    var old_mouse;
    var new_mouse;
    // picture is pressed and being scaled (or moved)
    //当图片被点击和缩放(或移动)。
    picture_mc.onPress = function(){

    // find the bounds of the picture clip
    // this will be used to compare with the
    // border property defined earlier to see
    // where the picture is being clicked
    //查找图片剪辑的范围,这个将用来和边界属性比较得出图片哪里被点击了。
    var bounds = this.getBounds(this._parent);

    // update manipulate’s x property depending on
    // whether or not the user clicked the left or
    // right borders
    //根据使用者是否点击左边或右边边界更新操作点X属性
    if (_xmouse < bounds.xMin + border) manipulate.x = -1;
    else if (_xmouse > bounds.xMax - border) manipulate.x = 1;
    else manipulate.x = 0;

    // update manipulate’s y property depending on
    // whether or not the user clicked the top or
    // bottom borders
    //根据使用者是否点击顶部或底部边界更新操作点Y属性
    if (_ymouse < bounds.yMin + border) manipulate.y = -1;
    else if (_ymouse > bounds.yMax - border) manipulate.y = 1;
    else manipulate.y = 0;

    // record the mouse position
    //记录鼠标坐标。
    old_mouse = new flash.geom.Point(_xmouse, _ymouse);

    // set the onMouseMove event to scale when the mouse is moved
    //设置onMouseMove事件用来缩放图片。
    this.onMouseMove = scalePictureMouseMove;
    }
    // delete the mouse move when released
    //当鼠标离开MC时删除onMouseMove事件。
    picture_mc.onRelease = picture_mc.onReleaseOutside = function(){
    delete this.onMouseMove;
    }
    // when moving the mouse in scaling or moving the picture
    //设置鼠标缩放、移动方法。
    function scalePictureMouseMove(){

    // record the current mouse position
    //记录鼠标当前坐标
    new_mouse = new flash.geom.Point(_xmouse, _ymouse);

    // find the difference between the old mouse
    // position and the new one
    //取得鼠标移动坐标差值
    var diff_mouse = new_mouse.subtract(old_mouse);

    // adjust the width and height of the picture
    // the use of manipulate makes this easy allowing
    // you to just multiply it by the difference
    // in mouse position. if the user did not click
    // on a border, manipulate would be 0 and there
    // would be no change
    //调节图片宽度&高度。
    //使用操作点可以轻易的允许你只要把鼠标坐标差值乘以它。
    //如果使用者没有点击边界,那么操作点将一直是0而不会改变。
    this._width += manipulate.x * diff_mouse.x;
    this._height += manipulate.y * diff_mouse.y;

    // determine if the user clicked on a border
    // if not, the user is dragging (moving) the image
    //确认使用者点击了边界,如果没有则使用者在拖动图片。
    var isDragging = Boolean(manipulate.x == 0 && manipulate.y == 0);

    // if the user is scaling left or up from a left
    // or top border, or if the user is dragging the
    // picture, offset the x and/or y position
    // of the picture to compensate
    //如果使用者点击左边界向左缩放或点击顶边界向上缩放,
    //或者使用者正在拖动图片,偏移图片的X&/或Y坐标以平衡。
    if (manipulate.x < 0 || isDragging) this._x += diff_mouse.x;
    if (manipulate.y < 0 || isDragging) this._y += diff_mouse.y;

    // set the old mouse to the current mouse so that it
    // can be used for the next onMouseMove event
    //设置old_mouse变量为当前值,以用于下一个onMouseMove事件。
    old_mouse = new_mouse;
    }

    相关文章:

    对"8ball里MovieClip类的新属性----scale9Grid"发表评论:

    热门Flash 最新Flash 热门小说 最新小说

     

    Copyright@2005-2006 精品Flash www.WooGood.com All Right Reserved

    联系信箱: gold1686tom.com