To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Search this Thread Display Modes
Old 10-16-2004, 11:33 AM   #1
suprpp
Junior Member
 
Join Date: Oct 2004
Posts: 3
Image moving around - detecting border of SWF and bouncing

Hi there, I am a bit of a newbie here and I've got a very silly problem. I've got an image moving around my SWF depending on what side of the .swf file the mouse cursor is.

Here it is: http://supr.is-a-geek.org/psd/flash.html

The problem is prolly very obvious: the image disappears when it should detect the border of SWF and bounce back.

here is the script for moving aorund:
code:

onClipEvent (load) {
x = 0;
}
onClipEvent (enterFrame) {
this._x += x;
if ((_root._xmouse>0) && (_root._xmouse<50)) {
if (x>-3) {
x -= 0.15;
}h
}
if ((_root._xmouse>715) && (_root._xmouse<765)) {
if (x<3) {
x += 0.15;
}
}
}



Any help would be much appreciated. Thanks!
suprpp is offline   Reply With Quote
Old 10-16-2004, 02:16 PM   #2
jbum
Senior Member
 
jbum's Avatar
 
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
code:

onClipEvent (load) {
x = 0;
// you'll need to adjust both of these quantities.
minX = -400; // minimum value for this._x
maxX = 400; // maximum value for this._x
}

onClipEvent (enterFrame) {
if (x < 0)
{
if (this._x + x < minX) this._x = minX;
else this._x += x;
}
else if (x > 0)
{
if (this._x + x > maxX)this._x = maxX;
else this._x += x;
}
// simplified these...
if (_root._xmouse<50) {
if (x>-3) {
x -= 0.15;
}
}
if (_root._xmouse>715) {
if (x<3) {
x += 0.15;
}
}
}

__________________

Last edited by jbum; 10-16-2004 at 02:18 PM.
jbum is offline   Reply With Quote
Old 10-16-2004, 07:03 PM   #3
suprpp
Junior Member
 
Join Date: Oct 2004
Posts: 3
Yay! It works and I even understand it! =) Thanks a lot!
suprpp is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 10:56 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.