皮休酷玩店开张啦,更多优惠选择
Flash MX 2004新特性实例学习一(2)
作者:中国动漫… 文章来源:网友提供 点击数: 更新时间:2008-9-11 9:54:12

8. 在主场景的时间轴上增加一个层,命名为“Action”,在此层的Action面板上增加代码如下:

  

  //注释1

  /* Copyright 2003 Macromedia, Inc. All rights reserved.

  The following is Sample Code and is subject to all restrictions

  on such code as contained in the End User License Agreement

  accompanying this product.

  */

  //注释2

  display.onEnterFrame = function () {

  if (Selection.getFocus() != null) {

  var mcfocus:MovieClip;

  var mcloc:Object = {x:0, y:0};

  // Get the object that's in focus

  mcfocus = eval(Selection.getFocus());

  // Set the label

  this.label.text = mcfocus;

  // Get the location of the object in global coordinates

  mcloc = {x:mcfocus._x, y:mcfocus._y};

  mcfocus._parent.localToGlobal(mcloc);

  //注释3

  // Move the arrow to point to it

  this._parent.arrow_mc._x = mcloc.x;

  this._parent.arrow_mc._y = mcloc.y;

  } else {

  //注释4

  label.text = "There is no object in focus.";

  this._parent.arrow_mc._x = 0;

  this._parent.arrow_mc._y = 0;

  }

  }

  //注释5

  function onClick (evt) {

  if (evt.target.selectedRadio == radio_single) {

  colorList.multipleSelection = false;

  } else {

  colorList.multipleSelection = true;

  }

  }

  //注释6

  radioGroup.addEventListener("click", onClick);

  radio_single.selected = true;

  2004中的Action跟MX的Action有很大的区别,所以尽量详细的解释。

  

   注释1:是版权信息,实例的来源是在Flash MX 2004的帮助文件中,所以保留这样的版权信息。

    注释2:这个函数是根据鼠标选定的组件来更改在Display中显示的内容。

    注释3:将箭头移动到鼠标选定的组件附近。

    注释4:鼠标没有选定如何组件,将箭头放在左上角。

    注释5:是Radio Button的侦听函数,根据选定的Radio Button设置List组件中的属性。

    注释6:为两个Radio Button组件增加“click”的事件侦听,侦听函数为“OnClick”,并设置默认选择的Radio Button为单选。

  三、实际用途

  这个实例主要涉及的是UI组件和对组件的编程。UI组件的用途主要是在WEB方面,比如在用Flash制作网页中的表单时,丰富的组件和灵活的控制会让工作变得非常轻松。而且也提供了一个组件应用的思路:不单单可以将常用的东西封装成组件,也可以通过编程更灵活地控制组件。

【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
Google
友情链接
北京奥组委中央电视台凤凰卫视深圳广电集团山东电视台中国孔子网东阿阿胶深圳新闻网视觉中国中国插画联盟火星时代网
CGFinal中国视觉联盟中国动画联盟JOJO热情领域塞联阵GalaxyHeroCC漫画图库