Ah, I see now. It's kind of hard to find tutorials for actionscript and flash 
without using the commercial flash ide.

Thanks for the help!

Huub Schaeks <[EMAIL PROTECTED]> wrote:    .hmmessage P { margin:0px; 
padding:0px } body.hmmessage { FONT-SIZE: 10pt; FONT-FAMILY:Tahoma }   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=white 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.onLoad=function() {walkSpeed = 5;};
        this.onEnterFrame=function() {
            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: [EMAIL PROTECTED]
Subject: Re: [Swftools-common] _x and _y move everything? (bug?)
To: [email protected]

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 <[EMAIL PROTECTED]> 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=white 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.onLoad=function() {walkSpeed = 5;};
        person.onEnterFrame=function() {
            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