佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1801|回复: 4

action script 2.0 问题

[复制链接]
发表于 21-10-2009 10:00 PM | 显示全部楼层 |阅读模式
function makeLvl():Void{ //Places bricks onto Level
        //finding the array length of the lvl code
        //The index has to be currentLvl-1 because:
        //array indexes start on 0 and our lvl starts at 1
        //our level will always be 1 higher than the actual index of the array
        var arrayLength:Number = _root.lvlArray[currentLvl-1].length;
        //the current row of bricks we are creating
        var brickRow:Number = 0;
        //Now, creating a loop which places the bricks onto the stage
        for(var i:Number = 0;i<arrayLength;i++){
                //checking if it should place a brick there
                if(lvlArray[currentLvl-1][i] == 1){
                        //creating a variable which holds the brick instance
                        _root.attachMovie('mcBrick', 'brick'+i,_root.getNextHighestDepth());
                        //setting the brick's coordinates via the i variable and brickRow
                        _root['brick'+i]._x = 15+(i-brickRow*7)*75;
                        _root['brick'+i]._y = 10+brickRow*20;
                        //checks if the current brick needs a new row
                        for(var c:Number = 1;c<=10;c++){
                                if(i == c*7-1){
                                        brickRow ++;
                                }
                        }
                }
        }
}


请问下是什么COMMAND把LIBRARY里面的MOVIE CLIP放在SCREEN里.
上面那个CODE的来源是:
http://www.mrsunstudios.com/2009/01/tutorial-create-a-brick-breaker-game-in-as2-part-3/

_ROOT又是什么意思.

已经在这里做了点功课...
还是不明白>_<
回复

使用道具 举报


ADVERTISEMENT

发表于 22-10-2009 05:37 AM | 显示全部楼层
原帖由 kjying 于 21-10-2009 10:00 PM 发表


请问下是什么COMMAND把LIBRARY里面的MOVIE CLIP放在SCREEN里.
上面那个CODE的来源是:
http://www.mrsunstudios.com/2009/01/tutorial-create-a-brick-breaker-game-in-as2-part-3/

_ROOT又是什么意思.

...



1. attachMovie
2. 阅读 http://www.adobe.com/support/fla ... _dictionary633.html
回复

使用道具 举报

 楼主| 发表于 22-10-2009 01:12 PM | 显示全部楼层
原帖由 super-tomato 于 22-10-2009 05:37 AM 发表



1. attachMovie
2. 阅读 http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary633.html

那个_ROOT读过了....
不明白>_<

我试试看attachMovie



这里看到的是酱

myMovieClip.attachMovie(idName ,newName ,depth[,initObject ])


可是我找到的TUTORIAL是_root.attachMovie(xxxx,xxx,xxx)

假设我的MOVIECLIP名字是 theone
我要放进去是不是应该用.


theone.attachMovie(theone, theone1, 2);

我用上面的CODE没有东西出来....


要怎样改变MOVIECLIP在SCREEN里出现的位置?_?


对不起.还是新手...
回复

使用道具 举报

发表于 22-10-2009 07:39 PM | 显示全部楼层
原帖由 kjying 于 22-10-2009 01:12 PM 发表

那个_ROOT读过了....
不明白>_<

我试试看attachMovie



这里看到的是酱

myMovieClip.attachMovie(idName ,newName ,depth[,initObject ])


可是我找到的TUTORIAL是_root.attachMovie(xxxx,xxx,xx ...


_root 的解释要是看不懂英文,可以去搜索中文說明
搜索资料的时候顺便了解 _root, level, depth 与 this 的关系


注意 attachMovie 的使用說明,尤其是参数部分(parameters)

(idName:String, newName:String, depth:Number[, initObject:Object]);

遇到 String 文字類型就把文字放在 " " 之間, Number 即是数字類型
如 : theone.attachMovie("theone", "theone1", 2);

p/s: 第一参数是指 library 中的 linkage id, 所以該怎么使用你就该多話些時間到 google 搜索步驟教程
回复

使用道具 举报

发表于 25-10-2009 11:05 PM | 显示全部楼层
原帖由 kjying 于 22-10-2009 01:12 PM 发表

那个_ROOT读过了....
不明白>_<

我试试看attachMovie



这里看到的是酱

myMovieClip.attachMovie(idName ,newName ,depth[,initObject ])


可是我找到的TUTORIAL是_root.attachMovie(xxxx,xxx,xx ...

_root的用法通常指的都是Stage的Timeline,就是最外层的时间轴(简单来说)。在某些情况下_root的位置会改变,不过在进阶阶段应该不会遇到(我看到的例子是当你要将一个含AS的SWF档Import进另一个SWF档,就要考虑_root变位)
不过像Tomato大大说的,了解_root, this, depth等蛮重要。毕竟都是常常出现的字眼。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 13-6-2024 10:30 PM , Processed in 1.049949 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表