日历

« 2008-07-06  
  12345
6789101112
13141516171819
20212223242526
2728293031  

统计信息

  • 访问量: 218
  • 日志数: 2
  • flash数: 1
  • 建立时间: 2008-03-25
  • 更新时间: 2008-03-25

RSS订阅

我的最新日志

  • AS3.0显示对象变量与实例名称

    2008-3-25

    In Flash 9 when you create MovieClip instance on the screen and give it an instance name, you are doing two things:
    1. You're assigning the name property of the MovieClip instance to be the string equivalent to the instance name provided
    2. You're creating a variable in the current timeline with the name of the instance name that references that MovieClip instance

    Flash does this behind the scenes when you publish your SWF to help you manage your movie clips on the screen. It's important to note that this behavīor (specifically #2) is not seen with Actionscrīpt. For Example:
    Actionscrīpt Code:
    // my_mc is the instance name of a movie clip
    // created on this timeline
    trace(my_mc); // [object MovieClip]
    trace(my_mc.name); // my_mc

    // create a new movie clip via AS
    // add it to my_mc
    var another_mc:MovieClip = new MovieClip();
    another_mc.name = "child_mc";
    my_mc.addChild(another_mc);

    // instance name not available in parent timeline
    trace(another_mc)// [object MovieClip]
    trace(my_mc.child_mc); // undefined
    trace(my_mc.another_mc); // undefined
     


    You can see that neither the instance name (name property) nor the variable to which the new MovieClip created with Actionscrīpt was assigned is referencable through the movie clip in which it was added (my_mc). This is because another_mc was created and added to the timeline dynamically. Flash will only save instance names as variables for movie clips created on the timeline in Flash.

    If you want to use an instance name to get a MovieClip (or any DisplayObject) instance from the timeline in which it exists, you can use getChildByName();
    Actionscrīpt Code:
    trace(my_mc.getChildByName("child_mc"))// [object MovieClip]);
     

    This will work for all movie clips despite where or how they were located as long as they are within the timeline/movie clip from which getChildByName was used.
     
     
       这是一篇从国外网站
  • 改变你的帧频stage.frameRate

    2008-3-25

    Using Actionscrīpt 3, you can dynamically change the frame rate of your movie using the Stage class.

    The Stage class (flash.display.Stage) is the class assigned to the stage object which is accessible from your main movie sprite/movie clip (or others within the same security sandbox) using the stage property. The stage object has a frameRate property which can contain any value between 0.01 and 1000 and determines the frame rate at which the Flash player plays back your movie. Changing this value lets you change the frame rate at runtime.

    Actionscrīpt Code:

    // change frame rate to 12 fps: 

    stage.frameRate = 12;

     
     
     
     
      
        AS3.0可以通过stage类动态的改变帧频.
        帧频的值可以在0.01~1000之间进行变化,如果你设置为0的时候实际上并不是0应该近似于0.01,在一篇文章里面曾经看过简单的通过设置帧频为0,可以让Flash停止。试了一下发现确实挺爽。又多了一种让影片暂时停止的方法。
Open Toolbar