Can't interact with tiles in an interactive jigsaw puzzle (Flash CC AS3)

你。 提交于 2019-12-12 04:06:54

问题


I am am doing this for a interactive assignment for a media arts class and I have no idea how to code in action script 3. I took the orignal code from a tutorial and it didn't work so I came here and attempted to learn how to modify it.

AS3 Code

//*********************
// Initialize:

flash.events.MouseEvent
var numPieces = 16;

for (var i = 0; i < numPieces; i++)
{
    var pieceName = "p" + (i + 1);
    var piece = this[pieceName];
    if( piece ){
        piece.name = pieceName;
        piece.addEventListener(MouseEvent.MOUSE_DOWN, function)(evt) 
        {
            this.scaleX = 1;
            this.scaleY = 1;
            this.shadow = null;
            this.parent.addChild(this);// Bump to top
            this.offset = {x:this.x - evt.stageX, y:this.y - evt.stageY};
        });
        piece.addEventListener(MouseEvent.MOUSE_MOVE, function) 
        {
            this.x = evt.stageX + this.offset.x;
            this.y = evt.stageY + this.offset.y;
        });
        piece.addEventListener(MouseEvent.MOUSE_UP, function)(evt) 
        {
            var target = this.parent["t"+this.name.substr(1)];
            if( target && hitTestInRange( target, 30) ){
                this.x = target.x;
                this.y = target.y;
            }
        });
    }
}

function hitTestInRange( target, range )
{
    if( target.x > stage.mouseX - range &&
        target.x < stage.mouseX + range &&
        target.y > stage.mouseY - range &&
        target.y < stage.mouseY + range )
    {
        return true;
    }
    return false;
}

Please help me fix this code so I can run my puzzle and move the pieces. I can upload the flash file if needed

来源:https://stackoverflow.com/questions/30770197/cant-interact-with-tiles-in-an-interactive-jigsaw-puzzle-flash-cc-as3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!