swftools-common
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Swftools-common] _x and _y move everything? (bug?)


From: Huub Schaeks
Subject: RE: [Swftools-common] _x and _y move everything? (bug?)
Date: Mon, 14 Apr 2008 22:01:53 +0200

Hello Jon

I'm no actionscript expert myself, but my guess is that if you put the ".filled person" on the stage like you did, it's just a shape, not a movieclip. Only movieclips have onEnterFrame events and shapes don't have onLoad events either, so I think that when you specify handlers for those events the way you did these handlers get assigned to those events for the stage , which is a movieclip. So the _x and _y refer to the position of the whole stage.

The code below works as I think you intended. What I did  was put the  ".filled person" into a sprite first (renaming it to person_shape) and put that sprite onto the stage. I assigned the handlers explicitly to the 'stage'-events and specified that the "person" sprite was to be moved.

Regards,
Huub

.flash name="persondemo.swf" bbox=1000x1000 background="" compress
    .outline person_outline:
        M 35 1.65625 C 21.2 1.65625 9.9999996 12.856249 10 26.65625 C 10 34.834223 13.923281 42.094201 20 46.65625 L 1.4375 46.65625 L 1.4375 118.78125 L 67.15625 118.78125 L 67.15625 46.65625 L 50 46.65625 C 56.076719 42.094201 60 34.834222 60 26.65625 C 60 12.85625 48.8 1.65625 35 1.65625
    .end
    .filled person_shape outline="person_outline" color=black fill=blue line=7
    .sprite person
        .put person_shape
    .end
    .box b1 100 100 color=black fill=black
    .put b1 x=200 y=200
    .put person x=0 y=0

    .action:
        this. {walkSpeed = 5;};
        this. {
            if (Key.isDown(Key.UP)) {
                person._y-=walkSpeed;
            }
            if (Key.isDown(key.RIGHT)) {
                person._x+=walkSpeed;
            }
            if (Key.isDown(key.LEFT)) {
                person._x-=walkSpeed;
            }
            if (Key.isDown(key.DOWN)) {
                person._y+=walkSpeed;
            }
        };
    .end
.end



Date: Mon, 14 Apr 2008 11:57:31 -0700
From: address@hidden
Subject: Re: [Swftools-common] _x and _y move everything? (bug?)
To: address@hidden

Try http://peachcobbler.uni.cc/persondemo.swf (without the www.) if the other link isn't working. My web host is being retarded. Sorry.

Jon Hartford <address@hidden> wrote:
If I compile the following code and load the swf, the arrow keys make all the objects in the movie move. Is this right or should it only move the object that the script is attached to? (the person, but not the box):

.flash name="persondemo.swf" bbox=1000x1000 background="" compress
    .outline person_outline:
        M 35 1.65625 C 21.2 1.65625 9.9999996 12.856249 10 26.65625 C 10 34.834223 13.923281 42.094201 20 46.65625 L 1.4375 46.65625 L 1.4375 118.78125 L 67.15625 118.78125 L 67.15625 46.65625 L 50 46.65625 C 56.076719 42.094201 60 34.834222 60 26.65625 C 60 12.85625 48.8 1.65625 35 1.65625
    .end
    .filled person outline="person_outline" color=black fill=blue line=7
    .box b1 100 100 color=black fill=black
    .put b1 x=200 y=200
    .put person x=0 y=0
   
    .action:
        person. {walkSpeed = 5;};
        person. {
            if (Key.isDown(Key.UP)) {
                _y-=walkSpeed;
            }
            if (Key.isDown(key.RIGHT)) {
                _x+=walkSpeed;
            }
            if (Key.isDown(key.LEFT)) {
                _x-=walkSpeed;
            }
            if (Key.isDown(key.DOWN)) {
                _y+=walkSpeed;
            }
        };
    .end
.end

Compiled: http://www.peachcobbler.uni.cc/persondemo.swf
(You have to click inside the bounding box to activate keyboard control.)


As far as I understand (I'm a newbie at actionscript, so it's likely I'm wrong), the person.onEnterFrame function is part of the person object, so it should only move the person, and not the box (b1).

It does the same thing if I put person._x and person._y, too.

I am using swftools 0.8.1 on Windows XP SP1. I haven't tried this with the current dev release.
 

 


Chat met al je vrienden. Voeg ze nu allemaal toe aan Messenger!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]