Go Back   kirupaForum > Flash > ActionScript 1.0/2.0

Reply
 
Thread Tools Display Modes
Old 10-16-2009, 12:22 PM   #1
ramart
Registered User
walk off then on stage

I have my movie clip walk off the left side of stage and come back on the right of the stage. but I cant get it to walk off the right and come back on the left can any one give advise please. this is what I have so far

onClipEvent(load) {
var direction = "left";
var speed = 10 ;
}

onClipEvent(enterFrame) {
if(Key.isDown(Key.LEFT)){
this.direction = "left";
this._x -= speed;
this.gotoAndPlay('walkleft');
if(this._x<0-this._width)this._x=Stage.width;
} else if(Key.isDown(Key.RIGHT)) {
this.direction = "right";
this._x += speed;
this.gotoAndPlay('walkright');
//if(this._x<0+this._width)this._x=Stage.width;
} else {

this.gotoAndPlay('wait'+this.direction);
}
trace(this._x);
}
ramart is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 10-16-2009, 01:14 PM   #2
RubenFlash
Registered User
Changes are in blue:

Code:
onClipEvent (load) {
    var direction = "left";
    var speed = 10;
}

onClipEvent (enterFrame) {
    if (Key.isDown(Key.LEFT)) {
        this.direction = "left";
        this._x -= speed;
        this.gotoAndPlay('walkleft');
        if (this._x<0-this._width) {
            this._x = Stage.width;
        }
    } else if (Key.isDown(Key.RIGHT)) {
        this.direction = "right";
        this._x += speed;
        this.gotoAndPlay('walkright');
        if(this._x>Stage.width){
            this._x=-this._width;
        }
    } else {

        this.gotoAndPlay('wait'+this.direction);
    }
    trace(this._x);
}
RubenFlash is offline   Reply With Quote
Old 10-18-2009, 09:14 AM   #3
ramart
Registered User
thanks very much Ruben I will give that a go after work
ramart is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:14 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com