all groups > flash actionscript > july 2004 >
You're in the

flash actionscript

group:

actionscript: stop object going of screen...


Re: actionscript: stop object going of screen... Todd Coulson
7/17/2004 3:16:34 PM
flash actionscript:
let's say your stage is 640x480 and your movie clip you are moving is called
car_mc:
code on main timeline:
this.onEnterFrame=function(){
if (car_mc._x>=640-car_mc._width|| car_mc._y>=480-car_mc._height){
//we know the car is outside of view, you can call a new function
that changes variables and changes direction of the clip
}
}

HTH's

--
Todd R. Coulson
multimedia developer - Haley Productions
todd@haleypro.com
search newgroups at: http://groups.google.com

[quoted text, click to view]

actionscript: stop object going of screen... wildteen88
7/17/2004 7:04:15 PM
Hi, people in the forum of flash.

I am stuck on settin a sort of boundry, That will stop objects going out of
view! I have a stage size of 400 px (width) and 400 px (height). I have made a
basic car game The problem is thought it dont stop at the end of the stage it
dissapears of viewable area!.

How would I stop this from happening?

info that may help:

car symbol name is car
Re: actionscript: stop object going of screen... IwannaFlashU
7/17/2004 7:55:13 PM
there's a much simpler way to do it...... without code.

MASK the layer that has the car in it:

1. Put a layer above your car layer.
2. Draw a box that covers the stage.
3. Right click on this layer and select mask.

It will automatically mask the layer directly below it and the car will only
appear on the stage, where that box is drawn.

Now you have two ways to go! =)
Re: actionscript: stop object going of screen... wildteen88
7/17/2004 8:07:55 PM
OKay, thank you for ur help

But, I am new to flash and Im gettin errors all over the place.

I have renamed my symbal to car_mc and put the script at the end of my car_mc
script.

i have an error that says the follow in:

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 51: Statement must appear
within on/onClipEvent handler
this.onEnterFrame=function(){

Total ActionScript Errors: 1 Reported Errors: 1

wot is this sayin to me. Sorry to be so blane.
Re: actionscript: stop object going of screen... Todd Coulson
7/19/2004 11:08:49 AM
First of all, I wannaFlashU- My way is better because your movie clip will
go off stage and cannot be rerouted to stay on the stage. It will not be
seen when entering the mask, but it will keep animating forever.

wildteen- You need to place my code this.onEnterFrame=function(){ code on
the maintimeline, make sure you are placing this code on the main root
timeline, not the button or movie clip itself.

--
Todd R. Coulson
multimedia developer - Haley Productions
todd@haleypro.com
search newgroups at: http://groups.google.com

[quoted text, click to view]

Re: actionscript: stop object going of screen... IwannaFlashU
7/19/2004 5:37:07 PM
Todd, when i first read the name of this thread and the initial post, I thought
he had everything working except the car was seen going off of the page (beyond
the stage) and thats what I was addressing.

Of course you have to have code to either bounce the car back the other way or
make it appear entering from the opposite side of the screen (ala asteroids) -
I thought he already had that code in his project. I misunderstood.

speaking of asteroids, here's a link to the tutorial on making that and some
of the ideas in there may give you some help on this project as well.

http://www.macromedia.com/devnet/mx/flash/articles/asteroids.html
AddThis Social Bookmark Button