Setting Bounds For An Mc (using Pixels...y = 300 Etc)
What I wanted to know is how I would be able to make it so that a certain mc could go no higher than say 300 pixels vertically. I know there's a way to limit movement that way but I'm not sure how to put it. My scenario is basically this: I have a character which is moved with the arrow keys, he has vertical and horizontal movement but I don't want him to be able to go any higher than about 300 otherwise it looks like he's walking on the walls .
Thanks,
Fargate
KirupaForum > Flash > Flash 8 (and earlier) > Flash MX
Posted on: 11-24-2004, 07:48 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Setting Bounds For An Mc (using Pixels...y = 300 Etc)
What I wanted to know is how I would be able to make it so that a certain mc could go no higher than say 300 pixels vertically. I know there's a way to limit movement that way but I'm not sure how to put it. My scenario is basically this: I have a character which is moved with the arrow keys, he has vertical and horizontal movement but I don't want him to be able to go any higher than about 300 otherwise it looks like he's walking on the walls .
Thanks,
Fargate
Find Bounds Of Contiguous Transparent Pixels
I have the need to find the largest rectangle of ONLY transparent pixels in a transparent PNG. The transparent region is non-rectangular, so getColorBoundsRect returns a rectangle that also contains non-transparent pixels. Is there a way I can check for a rectangle that contains only the color I set?
Setting Bounds With HitTest
Ok this problem is really starting to get annoying
ActionScript Code:
onClipEvent (enterFrame) { if (_root.line.circle.dot.hitTest(_root.mc)) { _root.gotoAndStop("end"); }}
That hittest performs when the two blue edgings around the two objects intersect. So it hittests just a little before it's supposed to. What I need to know and can't figure out is how to get it to Hit test when the actual objects interesect and not their borders.Thanks in advance .
Setting Bounds With HitTest
Ok this problem is really starting to get annoying
ActionScript Code:
onClipEvent (enterFrame) { if (_root.line.circle.dot.hitTest(_root.mc)) { _root.gotoAndStop("end"); }}
That hittest performs when the two blue edgings around the two objects intersect. So it hittests just a little before it's supposed to. What I need to know and can't figure out is how to get it to Hit test when the actual objects interesect and not their borders.Thanks in advance .
[help] Setting Bounds For A Mouse-related Movement
Hi,
I'm trying to build a parallax scenery and have the following so far:
code:
// the "oreja" object is declared because the function was formerly triggered by an onMouseMove event, but can't figure out how to keep it from being choppy
// oreja = new Object();
//scenery settings
var medio=Stage.width/2;
var medioV=Stage.height/2;
//velocity
var velo1=10;
var velo2=20;
var velo3=30;
//movement function
this.onEnterFrame = function() {
//distance between the mouse and the center of the stage
var hacia = Math.floor(_root._xmouse-medio);
var haciaV = Math.floor(_root._ymouse-medioV);
//unsuccessful attemp to set a bound
if(uno._x>0){
//horizontal movement
uno._x += hacia/velo1;
dos._x+=hacia/velo2;
tres._x+=hacia/velo3;
}
//vertical movement
uno._y += haciaV/velo1;
dos._y+=haciaV/velo2;
tres._y+=haciaV/velo3;
}
//Mouse.addListener(oreja);
But can't figure out a way to set bounds for the movement, so when the first plane reach a set position in _x and _y, it stops moving further. So far it only halts completely.
Any suggestions are welcomed. Attached is the result so you can see where I'm heading at.
Thanz in advance, salut!
Setting Bounds For A Mouse-related Movement
Hi,
I'm trying to build a parallax scenery and have the following so far:
ActionScript Code:
// the "oreja" object is declared because the function was formerly triggered by an onMouseMove event, but can't figure out how to keep it from being choppy
// oreja = new Object();
//scenery settings
var medio=Stage.width/2;
var medioV=Stage.height/2;
//velocity
var velo1=10;
var velo2=20;
var velo3=30;
//movement function
this.onEnterFrame = function() {
//distance between the mouse and the center of the stage
var hacia = Math.floor(_root._xmouse-medio);
var haciaV = Math.floor(_root._ymouse-medioV);
//unsuccessful attemp to set a bound
if(uno._x>0){
//horizontal movement
uno._x += hacia/velo1;
dos._x+=hacia/velo2;
tres._x+=hacia/velo3;
}
//vertical movement
uno._y += haciaV/velo1;
dos._y+=haciaV/velo2;
tres._y+=haciaV/velo3;
}
//Mouse.addListener(oreja);
But can't figure out a way to set bounds for the movement, so when the first plane reach a set position in _x and _y, it stops moving further. So far it only halts completely.
Any suggestions are welcomed. Attached is the result so you can see where I'm heading at.
Thanz in advance, salut!
Setting All Bitmapdata Pixels Transparent
Hi
i've got a bitmapdata "bmp"
already transparent, already created
i am loading a sequence of pngs with an alpha channel into it
after the new png is loaded i want to ERASE the contents of bitmap
and draw the new png so the images do not accumulate....
floodfill method is not working,
//SET TRANSPARENT (not working)
bmp.floodFill(0, 0, 0x00000000);
//REDRAW
bmp.draw(target_mc)
all help appreciated,
jhave
FlashMX Pixels Vs Photoshop Pixels?
In creating an animated Flash banner using a JPG graphic created in Photoshop 7, I set the flash document size to match the size of the backround graphic. According to PS 7, the image size is 503x90 pixels. This should fit exactly into a Flash document sized 503x90... yet when I bring the image into Flash, the image is about 2pix x 2pix smaller than the flash doc... this throws a border which causes the other images in the web page to not line up correctly.
Is this a known problem? Why doesn't Flash 503pix X 90 pix match with Photoshop's 503x90?
Thanks for your help.
steve
Get Bounds
hey pplz, is get bounds used for games????
coz i want to know how to make it so that when my character moves over a hill he will go over the hill and walk up a little, if u know wot i mean.
also , this has no relation lol , how duz Xiao Xiao make it so that when u push that button, it slows the frame rate and it goes in slow motion ( XIAO XIAO 3 )
thanx pplz
Skribble
_______________________________
www.skribblinteractive.tk
Out Of Bounds?
Hello... If a user drags a piece off the screen my program goes crazy.
www.enjoychess.com. Grab a piece and take it all the way to the edge of the screen and you will see what I mean.
I have event handlers and boundaries set and they work, but when the user takes the piece all the way to edge it goes nuts.
Any idea? Thanks!!
I am using flash mx 2004 pro
ANDY
Bounds
Hello,
I have a big problem in my game. I can not make bounds! In a way I can but not in this case. The problem that it's the background that is moving, not the car. So I would really appreciate if someone could explain me how to do it.
Thanks.
Here is the script I put on the background (the car is called "bil") :
onClipEvent (load) {
speed = 8;
}
onClipEvent (enterFrame) {
if (key.isdown(key.LEFT)) {
_x += speed;
}
if (key.isdown(key.RIGHT)) {
_x -= speed;
}
if (key.isdown(key.DOWN)) {
_y -= speed;
}
if (key.isdown(key.UP)) {
_y += speed;
}
}
onClipEvent (enterFrame) {
if (_root.bil.hitTest(_root.Wall4) or _root.bil.hitTest(_root.wall5) or _root.bil.hitTest(_root.wall6) or _root.bil.hitTest(_root.wall7) or _root.bil.hitTest(_root.wall8) or _root.bil.hitTest(_root.wall9) or _root.bil.hitTest(_root.wall10) or _root.bil.hitTest(_root.wall11) or _root.bil.hitTest(_root.wall12)) {
speed = 0.1;
} else {
speed = 8;
}
}
And this one on the car :
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_rotation = 90;
}
if (Key.isDown(Key.LEFT)) {
_rotation = 270;
}
if (Key.isDown(Key.UP)) {
_rotation = 0;
}
if (Key.isDown(Key.DOWN)) {
_rotation = 180;
}
if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP)) {
_rotation = 45;
}
if (Key.isDown(Key.LEFT) && Key.isDown(Key.UP)) {
_rotation = 315;
}
if (Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN)) {
_rotation = 135;
}
if (Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN)) {
_rotation = 225;
}
}
Scrolling Bounds >?
hey ,
i have a mc called pic ,i am tring to have it appear at the _x pos when it scrolls out of the 300 width area to start over again ..
here is what i have for the arrow keys ..
*********i didnt add any of the code examples for the _x pos ..but the stage is 300x50
Code:
myListener = new Object();
myListener.onKeyDown = function() {
if (Key.getCode() == 37) {
picture._x -= 2;
}
};
Key.addListener(myListener);
myListener = new Object();
myListener.onKeyDown = function() {
if (Key.getCode() == 39) {
picture._x += 2;
}
};
Key.addListener(myListener);
cheers ..
Bounds For DraGging
Does anyone know how to create bounderies for a dragable object, so when the side of it gets to the bounderies it stops moving on either the X or Y axis depending on where ti hits?
thanks in advance
-Stwelin
[F8] Get Bounds - Whole Screen
I remember reading this code somewhere but now I canīt remeber or find it. If You want to have the "get Bounds" from the whole screen. So if You have a swf with many drag-objects. So the user doesnīt by accident drag something outside the screen and canīt find it again.
Bounds:Object
Hi
I need to check the bound of a rotating object. The code below has two versions: A) rotates the block itself and B) rotates a block within the movieClip. Only B works but for the purposes of my game I need A to work.
I've attached the test app.
Code:
var bounds:Object;
function rotationControl(evt:Event):void {
// A
this.testBlock.rotation += 5
//
bounds = this.testBlock.getBounds(this.testBlock);
this.guideLine1.x = this.testBlock.x + bounds.x;
this.guideLine2.x = this.testBlock.x + bounds.x + bounds.width;
// B
this.testBlockB.block_gr.rotation += 5
//
bounds = this.testBlockB.getBounds(this.testBlock.block_gr);
this.guideLine3.x = this.testBlockB.x + bounds.x;
this.guideLine4.x = this.testBlockB.x + bounds.x + bounds.width;
}
this.addEventListener(Event.ENTER_FRAME, rotationControl);
Thanks
[CS3] Scaling With Bounds
Hey all, I'm trying to create a function to zoom/in out on a map with bounds using a scrubber. Was wondering if anyone has ever run into a similar situation/solution. What I have so far doesn't seem to quite work:
PHP Code:
function onZoomAdjust(pct:Number):void {
var cx = stage.stageWidth/2 - map.x //determine center point of map on x
var cy = stage.stageHeight/2 - map.y
scale = maxScale * pct + minScale //new scale pct based on slider
var tx = (cx * scale)/2 //translation of x
var ty = (cy * scale)/2
map.x = tx;
map.y = ty;
map.scaleX = map.scaleY = scale
}
It gets me pretty close but there's no control to stop the user from zooming out of bounds. Is this the sort of thing I need to use a matrix for?
Thanks
Bounds In Flash?
i have a "circle_mc" movie clip and its registratoin is in the center but it moves and works fine but i dont want it to go off the stage half way i want it to stop before it goes off
anyone?
ActionScript Code:
circle_mc.onRollOver = function() {
this.dx = Math.round(Math.random()*Stage.width);
this.dy = Math.round(Math.random()*Stage.height);
this.onEnterFrame = moveIt;
};
function moveIt() {
this._x += (this.dx-this._x)/10;
this._y += (this.dy-this._y)/10;
if (Math.round(this._x) == this.dx) {
this._x = this.dx;
}
}
-aldo
StartDrag Bounds
So I'm doing what I would normally do in AS 2 and it's not working. On press of my clip I am getting
Code:
Argument count mismatch on flash.display::Sprite/startDrag(). Expected 0, got 6;
Live docs don't have an example on how to set bounds.
Does startDrag not take any parameters?
Any links or anything?
TIA
Expand Out Of Bounds
Given a flash file with dimensions, like 300x400 embedded on an xhtml page, is there a way to allow the content to spill out of the box and over other elements? Ive seen this done on ads, but I want to use it for a navigation. Does anyone know how they do it?
Expanding Beyond The Bounds...
I'm attempting to do some Rich Media design, and have run into a snag. I have a banner (768x90) that will expand once hovered over. Best example I've run into is something like THIS where it expands from the 90 high to about 270 total. There's a lot of other examples at PointRoll under the FatBoy category.
I need help on how to get the additional content to display outside of the original Flash file. It appears as though it's all one file, the 'bounds' of the stage simply expand to accomodate it, but I can't figure out exactly how to get this done.
Thanks in advance.
Mouse Bounds
I currently have a Nav that I am working on that will follow the mouse's _y position. I am wanting to have bounds set that keep the nav in between certain top _y and bottom _y, but am lost on how to do it.
I have tried applying the same techniques that I would to create bounds for a Dragging menu (define top and bottom bounds) but it didn't work with the mouse position.
Here is the code so far that makes the menu follow the mouse:
speed = 25;
menu_mc.onEnterFrame = function () {
target_y = _root._ymouse - this._y;
this._y = this._y + (target_y/speed);
}
Any help would be appreciated.
Thanks,
--
Michael
Change Scroller Bounds?
Hey guys I found this code that uses duplicate clips and xml to have a gallery, but I need to change the bounds of the scroller (the amount showing at one time) to make it wider. Here are the following movieclips and their script.
Thanks,
Eric Ehle
bb:
while (i < Laenge) {
a1.duplicateMovieClip("a" + i, i);
a = this["a" + i];
a._x = 6 + (123 * i);
a._y = 150;
i++;
dragger:
if (_root._xmouse < 465) {
startDrag ("_root.dragCTRL", true, 25, 0, 465, 282);
} else {
stopDrag();
}
dragCTRL:
var slidePercent = int (((_level0.dragCTRL._x - 25) * 100) / 440);
newX = int (((((_level0.bb.Laenge * 123) - (435 + (20 / (_level0.bb.Laenge / 2)))) / 100) * slidePercent) * -1);
_level0.bb._x = _level0.bb._x + ((newX - _level0.bb._x) / 10);
Laenge = codeArray.length;
Constraining Mouse OUTSIDE Bounds
Hi all,
Im creating a simple FLASH, shooting game, and trying to implement some
actionscript which constrains where the user can move the mouse.
As an example. Imagine a blank stage, with medium sized rectangle in the
middle. I want the user to be able to position/move their mouse anywhere
around the rectangle, but being unable to position the mouse within the
rectangle.
Basically, i want to contrain the bounds of the mouse OUTSIDE the rectangle.
(constraining the mouse within the rectangle is easy)
If someone could post the code, or point me to an online example i would be
most grateful
Cheers
Paul
Help Me Solve A Problem Bounds Of MC
Hi all,
Goh, im stuck.
I am trying to get the width and height of a movie clip, disregarding the rotation.
Here is my problem.
I have a MC called "canvas" which holds a few other MCs called "layer1", "layer2", etc.
These layer MCs can be streched, rotated, etc via buttons. If they are rotated or streched, i want to get their new widths.
The problem is, i do not get the right values once i rotate the MC. I figured it wa because flash was going off of the bounding box of the layerMC so i tried the getBounds method and this also only returns the correct value if the MC has not been rotated. How would i get the stage width, stage height of a MC regardless of its rotation. As in if its a rectangle 10x100 pixels, and i rotate it 90 degrees, it should be 100x10 respectivly. So far the only thing that causes problems is the rotation of the MC, scaling returns correct values.
Also, the CANVAS movie clip also gets scaled (zoomed in) though that has not been much of an issue thus far, it may be causing the wrong values.
Any ideas? PLZ HELP!
[F8] Bounds Of Movie, Stop Car
I want the car not to go off stage basically. I doubt im doing this right at all:
var stage.Width = sw
var stage.Height = sh
if ((this._x>sw) || (this._y>sh)){
_root.object.objectspeed *= -1
}
do I need some math in there somewhere?
Modifying The Bounds Of A Clip
I have a big movieclip but I just want to show a little peace of this movieclip. So I mask it with another movieclip with rectangles drawn in it and blendmode "alpha". The problem is that the rest of the clip (the masked part) is just then considered with _alpha=0; so actionscript always consider this clip as the whole big movieclip and it takes time to draw it on the screen.
So is it possible to really change (decrease) the bounds of a movieclip?
AS 3 Random Motion Within Bounds
Ok,
I have a script that produces random motion along the y axis, however, I want that motion to occur within the movie clip that is centered on the stage, or I should say within the bounds of that movie clip.
The movie clip has a height of 335 px
Here is the code:
Code:
var xTween:Tween;
var yTween:Tween;
startTween();
function startTween(e:TweenEvent = null):void {
yTween = new Tween(box, "y", Elastic.easeInOut, box.y, Math.random()*300, 2, true);
yTween.addEventListener(TweenEvent.MOTION_FINISH,startTween);
}
any help is appreciated
Thank you
-D
Constraining Motion/bounds
Hello.
I'm trying to solve a problem I have. Imagine you have a series of handles sat on a horizontal plane, they can be moved left to right...
___/\_____X_____/\_X_/\___X____/\___________
The X amounts are driven by the distance between the two points, simple. Now, when the objects move the distance shrinks, also simple...
___/\__X__/\_X__/\___X____/\________________
Now, what I want to be able to do is move the first triangle (well, any one but the first for this example) to the right, beyond the point where the second or third objects are. I want it to push those objects along as I move it, then when I drag it back it leaves them there. I then want to be able to drag the second object to the left, where it will 'hit' and push the first object out of the way.
In 3D I'd call this 'bi-directional constraints', I'm not familiar how to do it in AS3.
Any help would be great.
A.
Control Bounds Of Sliding Mc
I have this script attached to a mc (see below) that makes the mc slide across the x-axis. That part works great, but I only want the mc to go so far to the right and I don't want the mc to move when you are not over the mc (ie. anywhere else on the stage). Does anyone have any suggestions as to what I can add to this script to control that or do I need a different script? Any help would be appreciated.
onClipEvent (enterFrame) {
//x movement
mx=_root._xmouse;
if (mx<_x) {
dx=_x-mx;
}
else {
dx=mx-_x;
}
moveSpeedx=dx/5;
if (mx<_x) {
_x=_x-moveSpeedx;
}
else {
_x=_x+moveSpeedx;
}
}
Help Me... Its The Bounds And Grass (:P) There Is The Problem
Hello my fellows!
I have a problem with bounds. I have seen HERE and when the blue stick brother there goes into grass he can not just walk over it. What AS should I write to do the same thing.
I need bounds that also work with a moving background.
Thanks
Finding The Bounds Of A Movieclip
Version: Flash CS3, AS3
Is there a way to find the bounds (width&height) of a single-frame movieclip in a way that disregards surrounding whitespace?
ie. if a movieclip contains only a 10x10 square at point 5,5 (within the movieclip), width&height is normally returned as 15x15. I want a way to have 10x10 returned.
Flash seems to know of such bounds - the graphic displayed in the library sidebar is set to this size. So are they accessible via AS3?
Thanks
Rick
Calculating Perimeter - Bounds
Hi,
Here is the task simplified:
You have a grid on which you place boxes that snap together,
all boxes have to touch each other, once you finish you click
i finished and it ouputs the bound measures.
How would one get those measures?
Thank you!
tamagorci
Set Bounds For Window Component
I have a window component in MX2004 Prof. So it's a SWC and un editable. How can I set limits on where this window can be dragged?
Currently, the window can be dragged off the area it's in and then (when released) it is impossible to drag it back down and close it.
How can I set the boundaries of where it can be dragged (the draggable part, anyway) ?
Making Text In Bounds...
How can i make shure that every time a textfield reaches maxlimit to the right it automaticly hits enter? Like when i reaches the right limit of this textbok the word is automaticly moved down to a line below... Any1 understood that?
More Efficient Bounds Checking
Hey... I'm making a side-scrolling game. There are a lot of different objects in the 'room', all of which need hitTest checks to make sure the main character can't walk through them... I don't want to make every object a movie clip, because that would be tedious, and very inefficient (I have started doing this, but it slows down the swf rendered file). I was wondering if there was any other, quicker, better way to make it so my character can't walk through walls and such like that.
Thanks for any help.
Moving Object Out Of The Movie Bounds
I'm not sure if this is possible or not. I am using Flash5, and what I want to do is have a relatively small movie clip(flash animation) say like 20x20 pixels but have a larger floating, draggable clip that will sit over the HTML in the page... images, tables, background, etc... can anybody give me a hint on how to do this, if it can be done???
Thanks.
paco
Hit Test To Define Objects, Bounds
I'm creating a game but I have the problem of the characters running off the top of the screen and returning on screen from the bottom. How can I define a perimeter?
Also, if I want the characters to NOT be able to run through other objects on the screen, how do I define that on the actionscripting?
I am using flash mx 2004.
Clipping Bounds On Sprite/MovieClip
Easy noob question for you: I'm using addChild() to add bitmaps to a 100x100 Sprite. I'm positioning these bitmaps with their x and y parameters. However, if the bitmap 'spills' over the edge of the 100x100 Sprite, I want it to be clipped. In other words, if I place a 50x50 image at the x,y coordinates of 90, 90, I only want the upper-left corner 10x10 pixels of the image to be shown. Does that make sense? How can I do this? Is there some 'clip' parameter?
Thanks in advance!
-Rich
Click, Drag, Stay In Bounds....Please.
Hey guys, I need help here. I've been searching this forum and found many versions of what I want but not exactly. I know this probably easy for you guys, but I've been spending days trying to figure this out, ...yes I know I'm a newbie.
Basically I have a click and drag MC on the stage, but I want to confine it to the stage, not having it go past it's edges.
...help!
Loaded .swf Into _mc Wont Stay Within Bounds
Basically I created a slide show (slideshow.swf).... which loads jpgs dynamically into movie clips that I also created dynamically. I also created buttons that I exported for action script and load dynamically on the stage as well...
all contained in SlideShow.swf.....
When I load slideshow.swf into a movieclip (movieClipHolder_mc) in my Main movie
part of the movie ( the jpgs) stay within the bounds of the Slideshow.swf stage...
however the buttons I created dynamically inside of the slideshow.swf movie....
put themselves onto the main stage of my main movie....
I've checked the code and it seems right, but obviously I'm missing something....
Proportionate Resize Based On Bounds
i have a container that is 100 x 100 and i have various symbols of different shapes and sizes (states for a U.S. map) that i am loading into that box and need to resize
some are bigger, some are smaller
can anyone help me figure out how to scale them proportionately larger or smaller depending on their size relative to the container.
here's what i have so far
Code:
attachMovie(_root.curState, "curState", 100, {_x:25, _y:15});
widthBound = 100;
heightBound = 100;
if (curState._width<widthBound && curState._height<heightBound) {
ratioWidth = Math.round(widthBound/curState._width);
ratioHeight = Math.round(heightBound/curState._height);
if (ratioWidth>ratioHeight) {
curState._width *= ratioWidth;
curState._height *= ratioHeight;
}
}
Possible To Clip Bounds Of Sprite/Movieclip?
Easy noob question for you: I'm using addChild() to add bitmaps to a 100x100 Sprite. I'm positioning these bitmaps with their x and y parameters. However, if the bitmap 'spills' over the edge of the 100x100 Sprite, I want it to be clipped. In other words, if I place a 50x50 image at the x,y coordinates of 90, 90, I only want the upper-left corner 10x10 pixels of the image to be shown. Does that make sense? How can I do this? Is there some 'clip' parameter?
Thanks in advance!
-Rich
Player Bounds Not Working Correctly
I'm working on a little space shooter scroller game, and I'm trying to set the bounds of where a player can go (the white ship). Right now, I have the green MovieClip (instance name: wall) acting as a collision object against the player's ship (instance name: player_ship).
This is the actionscript code I have currently on the player_ship.
Code:
onClipEvent(load){
//player ship
moveSpeed=10;
this.gotoAndStop(1);
//laser
_root.player_laser._visible = false;
laserCounter=1;
maxLasers=4;
laserDepthCounter=1;
//scroll scene
scrollStart=true;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if(!(_root.wall.hitTest(this._x, this._y, true))){
this._x+=moveSpeed;
}
}
else if (Key.isDown(Key.LEFT)) {
if(!(_root.wall.hitTest(this._x, this._y, true))){
this._x-=moveSpeed;
}
}
if (Key.isDown(Key.DOWN)) {
if(!(_root.wall.hitTest(this._x, this._y, true))){
this._y+=moveSpeed;
}
}
else if (Key.isDown(Key.UP)) {
if(!(_root.wall.hitTest(this._x, this._y, true))){
this._y-=moveSpeed;
}
}
if (Key.isDown(Key.SPACE) && (laserCounter<=maxLasers)) {
laserCounter++;
_root.player_laser.duplicateMovieClip( "player_laser"+laserDepthCounter, laserDepthCounter );
_root["player_laser"+laserDepthCounter]._visible=true;
laserDepthCounter++;
if (laserDepthCounter>maxLasers){
laserDepthCounter=1;
}
}
}
Here's the swf too if you're interested in seeing this in action (I'll eventually turn the green box transparent): http://www.mediafire.com/?fkxduyoe2mz
Basically, when the center of the player_ship hits the center of one of the 4 lines, it gets stuck. I've tried using getBounds(this).xMax and whatnot, but that only made it so the player_ship could sometimes escape the bounds box.
Code:
if (Key.isDown(Key.RIGHT)) {
if(!(_root.wall.hitTest(getBounds(this).xMin, this._y, true))){
this._x+=moveSpeed;
}
}
if I do a else statement on the hitTest() to move the player_ship a "moveSpeed" in the opposite direction, it also gets stuck if you don't let go of the arrow key at the right time, so then you have to tap it again to nudge it out.
Code:
if (Key.isDown(Key.RIGHT)) {
if(!(_root.wall.hitTest(this._x, this._y, true))){
this._x+=moveSpeed;
}
else{
this._x-=moveSpeed;
}
}
Any ideas on how you're supposed to properly make a boundary box to constrain a player? I'm stumped now that all these things I tried haven't worked.
Mouse Detecting Bounds Of Screen
I have a flash file at :http://stalworth.bvdhosting.com/test/properties.php which has a movie clip attached to the mouse using the startDrag() function when you hover over a green county.
It works fine, but if you select a county on the left side of the file, the MC extends past the edge of the screen. So i have an onclipEvent (enterframe) function that says "if the mouse is less than 200 pixels from the left, move the hovering MC 400 pixels to the right" and you can see it works.
The problem is that the code does not execute fast enough, and flickers from the left to teh right. How should i execute that code in order for it to happend before the hover is displayed?
Thanks for your help
Drag Glitch When Mouse Goes Out Of Bounds
you can see here: http://www.lisag.xtreemhost.com/magicball/new/ball.html
It happens when you drag the scroll slider out of bounds and you release - even when mouse is up the slider still moves. I consider it a glitch. What does somebody has to do to fix it?
the code I use for the slider:
Code:
scroll_btn.buttonMode = true;
var dragging:Boolean = false;
var bounds:Rectangle = new Rectangle(-10,-13,0,138);
up_btn.addEventListener(MouseEvent.CLICK,onUp);
down_btn.addEventListener(MouseEvent.CLICK,onDown);
scroll_btn.addEventListener(MouseEvent.MOUSE_DOWN,onDrag);
stage.addEventListener(MouseEvent.MOUSE_UP,onDrop);
stage.addEventListener(Event.ENTER_FRAME,checkDrag);
lt_txt.addEventListener(Event.SCROLL,onScroll);
function onUp(e:MouseEvent):void{
lt_txt.scrollV-=1;
}
function onDown(e:MouseEvent):void{
lt_txt.scrollV+=1;
}
function onDrag(e:MouseEvent):void{
dragging = true;
scroll_btn.startDrag(false,bounds);
}
function onDrop(e:MouseEvent):void{
dragging = false;
scroll_btn.stopDrag();
}
function checkDrag(e:Event):void{
if (dragging) lt_txt.scrollV=Math.round((scroll_btn.y-bounds.y)/bounds.height*lt_txt.maxScrollV);
}
function onScroll(e:Event):void{
scroll_btn.y = Math.round(bounds.height*lt_txt.scrollV/lt_txt.maxScrollV + bounds.y);
}
Please Help if you can!
Scroll Any MC Four Directions And Zoom But Within Bounds? How To Structure This?
Hi,
I keep coming back to the same issue, trying to rebuild this navigation system so it will accept any content without modification.
What is it? I'm making a navigation system that will scroll any-sized movieclip content (not text!) left & right & up & down as well as zoom in and out. It scrolls using two typical scrollbars with up & down buttons and a dragger in the middle. The zoom happens using "+" & "-" buttons and also has a dragger in the middle. My problem is, I am trying to do this as dynamically as is possible. And I've run into certain issues:
1. How can I always keep the MC within the bounds of my masked area when scrolling it using the getBounds() function, regardless of the size it's been zoomed or shrunk to? Of course, I will set bounds on the zoom levels too, but the scrolling is more of an issue. I assume i will use the border of the masked area as the MC to getBounds()? Just not familiar with it.
2. If I am scrolling the MC in all four directions and zooming the MC in and out, is it best to put the content's registration point at the center or at the top left corner? Flash uses the registration point to get it's position but I am concerned since it is harder to determine the true position of the MC's top and bottom when it's centered than when it's reg point is at the top left corner. At the same time, when I zoom, I would like it to zoom evenly in all directions and that would not happen if I set the reg point to the top left corner.
The same issue lies with the border MC that would be used with getBounds(). Would the reg point be centered or top left corner?
So to summarize, what's the best way to set up the content and the border of the viewing area (which is likely what will be used with getBounds()?) And how does getBounds() work exactly? I am going through a tutorial using it in "Advanced Flash Actionscript" by Dan Livingston, but it's not really what I'm doing.
Thank you!! Any help is really appreciated. =)
Jessica
|