[AS2] Loading a AS2 class

This is so noobish… but how do I link to a AS2 class file?
Locally I’m doing this:

import com.gskinner.sprites.CollisionDetection;

and in the same dir of the swf I have the whole “com.gskinner.sprites.” directories.

But how I would do it to upload the swf? How do I point to an online as2 class file? :expressionless:

Bah. Thanks.

you can download his example fla files at this link.

Classes are compiled into the swf when the swf is generated/created. So, they aren’t needed on the web server - than can’t be utilized that way. The import statement needs to be in your fla on a frame - and depending on how he has it set up, you either create an instance of the class on the timeline something like: var foo:TheClass = new TheClass(items may need to get passed in there); or, classes can be linked to movieclips within the library - you can right click on a clip in the library and select linkage - and set things there.

Hope this helps.

import com.gskinner.sprites.CollisionDetection;
speed = 1;
hit = false;
function onEnterFrame() {
    if (CollisionDetection.checkForCollision(leader, room, 255)) {
        leader.gotoAndStop(2);
        hit = true;
    } else {
        hit = false;
        leader.gotoAndStop(1);
    }
    //******************
    if (Key.isDown(Key.RIGHT)) {
        if (CollisionDetection.checkForCollision(leader, room, 255)) {
            leader._x -= speed
        } else {
            leader._x += speed;
        }
    } else if (Key.isDown(Key.LEFT)) {
        if (CollisionDetection.checkForCollision(leader, room, 255)) {
            leader._x += speed
        } else {
            leader._x -= speed;
        }
    }
    //   
    
    if (Key.isDown(Key.UP)) {
        if (CollisionDetection.checkForCollision(leader, room, 255)) {
            leader._y += speed
        } else {
            leader._y -= speed;
        }
    } else if (Key.isDown(Key.DOWN)) {
        if (CollisionDetection.checkForCollision(leader, room, 255)) {
            leader._y -= speed
        } else {
            leader._y += speed;
        }
    }
    
}

That’s my code, but If I upload it to imageshack for example, it doesn’t work. :confused:

http://img81.imageshack.us/my.php?image=singleplayeroverviewxm0.swf

I’m trying to find out why the collition detection isn’t working. Locally it does, well… not too good…

does the collision detection happen with dynamically loaded images…? or flash drawn movieclips ?

So far with 2 simple MC’s.

“leader” and “room”.

It works… sort of. If you collide and keep holding the key it won’t go through the wall, BUT if you let go and there’s a collision still taking place you can press the opposing key and you’ll go through the wall…

That’s why I want to upload it, so you guys can see what’s up…