Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Flash Squares Emergency



Oh man I've been sitting here thinking of a way to do this but I can't think straight. My mind has gone to sleep and I'm panicking. I have a tight deadline of Tuesday to this and with a lot of work still to do I can't seem to get my brain in gear.

Does anyone have an idea how to make squares fly at the screen?

If you think in a movie (a real movie) and think of the user as a camera, I wanna make the squares fly towards the user and then kind of past them (but that won't be shown)?

Is this clear what I'm trying to do?

I was hoping someone had seen a tutorial or something else that may help me. My brain is numb and I'm just making myself angrier and angrier that it won't work.

help....please



KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 04-29-2005, 07:21 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Flash Squares Emergency
Oh man I've been sitting here thinking of a way to do this but I can't think straight. My mind has gone to sleep and I'm panicking. I have a tight deadline of Tuesday to this and with a lot of work still to do I can't seem to get my brain in gear.

Does anyone have an idea how to make squares fly at the screen?

If you think in a movie (a real movie) and think of the user as a camera, I wanna make the squares fly towards the user and then kind of past them (but that won't be shown)?

Is this clear what I'm trying to do?

I was hoping someone had seen a tutorial or something else that may help me. My brain is numb and I'm just making myself angrier and angrier that it won't work.

help....please

Flash Game - Calculating Squares..help
Hi Everyone,

I need a little help with a simple Flash game I need to create and any thoughts would be much appreciated.

I have 10 squares which can be turned into 1 of 4 colors by clicking on them. You choose the color of the square depending on what stage you are at in the program: red if you havent started a certain chapter, green if you have completed it, etc.

After you have set all 10 squares to the appropriate color, you hit submit and depending on the number of red, green, blue and orange squares, you will be taken to the appropriate page for the stage you are at.

Now, there are (I havent actually calculated yet) alot of different possible ways the squares could be colored when you hit submit...5 red, 2 green, 2 blue, 1 orange..etc etc.

Can anyone help with how I would calculate the number of different colored squares and then how to send to the appropriate page?

Anyone do anything similar to this before?

Thx!

PS: Im using Flash 8

Rob

Flash Game - Calculating Squares..help
Hi Everyone,

I need a little help with a simple Flash game I need to create and any thoughts would be much appreciated.

I have 10 squares which can be turned into 1 of 4 colors by clicking on them. You choose the color of the square depending on what stage you are at in the program: red if you havent started a certain chapter, green if you have completed it, etc.

After you have set all 10 squares to the appropriate color, you hit submit and depending on the number of red, green, blue and orange squares, you will be taken to the appropriate page for the stage you are at.

Now, there are (I havent actually calculated yet) alot of different possible ways the squares could be colored when you hit submit...5 red, 2 green, 2 blue, 1 orange..etc etc.

Can anyone help with how I would calculate the number of different colored squares and then how to send to the appropriate page?

Anyone do anything similar to this before?

Thx!


Rob

Flash Player Shows Vague Squares
this happend to me when I installed Flash 9 or so, don't really remember annymore.
but when I try to watch movies now, I see a vague square around each moving object (I ghues you call them "icons").
annyway, this kind of removes the smoothness of flash, the square is usually a bit lighter coller than the background it is on.
I would like to know a way to fix this and get Flash back to it's original smoothness.

http://s144.photobucket.com/albums/r187/Vyruz64/?action=view&current=Flashproblem.jpg
here is a link to a picture to show the problem.

Flash And Focus [emergency]
I have a flash movie that has text input fields in it. the problem is, if I leave the browser, and then come back, flash loses focus (expected). is there ANY way to get focus back to the input fields without having to click on the movie.

I know you have to have to, but I'm hoping one of the genius's out there has gotten around this. I have used javascript to give the window focus,and it is getting it, but the input box cursors will not blink untill you click in the field.

any help would be great

thanks

IMS

Flash Form Emergency
I am facing a difficult problem. I have multiple forms within a flash website that are passed to PHP. All works as normal in that regard. However, on 2 of the forms there is a problem which is driving me crazy!!!

The form is normal, input text with variable names and a submit button. The problem is that the variable being passed to PHP includes all sorts of text formatting options, like this (this is the name field, I entered my name and traced the variable and get this result) -

<P ALIGN="LEFT"><FONT FACE="_sans" SIZE="9" COLOR="#000000" LETTERSPACING="0" KERNING="0">Andrew</FONT></P>

On another form in the website there is no problem, the variable passed is clean.
Please help, I have tried everything.

--- Newbie Needs Flash Help --- This Is An Emergency ---
Hello All,

Does anyone have a clue how to change the xml flash photo gallery here: http://www.kirupa.com/developer/mx2004/xml_slideshow.htm -

to allow for the photos to be resizeable, or for horizontal and vertical photos to arrive at different designated coordinates. This has been driving me crazy for days. Would appreciate some help. I'm an html and css wiz, but this xml stuff is pretty new to me. Thankya

EMERGENCY: Lost Flash Files
I was working on a few flash files from my external hard drive when I disconnected the drive by accident. All the files  that I had open in Flash now seem to have been deleted from the drive. Is there any way of getting them back or are Temporary Flash Files stored anywhere on my computer?

SEO Tips For Full Flash Site Please? EMERGENCY
Hi! I am semi-skilled with Flash and HTML and SEO for HTML. A friend got me a job building a website for a lawyer friend of his (let's call him Joe Smith). I showed him some templates, and he fell in love with a full-Flash site. The good news is that I built his site easily using this template and it looks fantastic. He really likes it.

But... I did not know beforehand that search engines are blind to full-Flash sites. And he has voiced his need to see his name indexed well by Google. I have researched this a bit and I now realize that the best solution is to build him an HTML companion to the Flash site, but I can't do it in a short span of time. I feel bad - he's already paid me, but I can't just tell him "I don't know", because my friend's reputation is at stake for recommending me. I need to get this fixed in the next few days. Can someone please explain a simpler way to have Google show his site as a result when a person searches for "Joe Smith"? (note: his web address is www.smithlaw.com)

Thank you so much for your help!

Flash 2004 Emergency Conversion Utility 1.11
Not sure anyone seen this but would like to share with you guys.

http://www.menutec.com/flash2004.php

Regards Barrie

Emergency PROBLEM FULL SCREEN FLASH
Hello to everybody. I have a very big problem, that must be urgently solved. I need to make a full screen flash movie. I need this because i need to change the background color when i click a specific button.

I read the article about full screen in flash, but it not works perfectly
http://www.kirupa.com/developer/mx2004/fullscreen.htm

I can not see the whole movie horizontaly is OK, but vertycaly i see just a part of it. Could someone send me the code or help me in one way or another.

Thank you very much for your precious help!

Best regards, Jernej

Flash 2004 Emergency Conversion Utility 1.11
Not sure anyone seen this but would like to share with you guys.

http://www.menutec.com/flash2004.php

Regards Barrie

Squares
HI ..


I have a simple idea i want to do , i know that some one make it before.

i want to make a square - as a button - when you click on it all the screen will be coverd by squares (but not in a random way ) .


Any idea ??

Squares
Hi

any tutorials out there on how to create shuffling squares like on the digisoft studios website..or does anybody themselves know how to do it.

thanks

Squares
can somebody tell me how to add squares when is loading image like on this file
http://members.lycos.co.uk/xmalsiamusicx/header.swf thanx in advance

Sliding Squares Nav.
I've been trying to figure this out but I can't seem to get it right.. if anyone can help, PLEASE post a message.
I need to know how the shifting squares on this website work.
http://www.eskedahl.se/
thanks so much for your help.
erick.

Strange Little Squares
I'm testing an interface in flash mx where user can update his data through cold fusion and access db. Everything works fine exept that i always find little strange square symbols within updated data inside dataBase. So far I wouldn't mind 'cos the user gets his updated data back to the same interface without "squares" (unless it's ã or ê!!-why?). BUT, when it's about changing password of course we have a problem there, 'cos data base actually contains more characters then user has inputed. Thus the access is denied. How to GET RID OF SQUARES !!!!

thx
Alek

HitTest Squares
Hello! I am making a game and am having an issue with some hitTests... The main character runs around and theres plenty of things to run into that make him stop using:


Code:
if(_root.player.hitTest(this)) {
if(_root.player._x < this._x) {
_root.player._x = _root.player._x - _root.movespeed;
}
if(_root.player._x > this._x) {
_root.player._x = _root.player._x + _root.movespeed;
}
if(_root.player._y < this._y) {
_root.player._y = _root.player._y - _root.movespeed;
}
if(_root.player._y > this._y) {
_root.player._y = _root.player._y + _root.movespeed;
}
}
^ That code is in the MC he is running into.

The only problem with this is that for non square shapped things... hes running into an invisible square around the odd shaped thing. Is there a way to make the hit test check to make sure he's actually hitting an object and not just the box around it?

Also another problem with that code is that if you hold down the arrow key to keep running into the object he will be pushed up and down along the side.. I can see why it does that but I don't know how to fix it, any ideas?

Thanks

Rotating Squares
Hello.

I would like to create a square (in Flash MX), that rotates on it's X and Y axis when the mouse rolls over it.

Specifically, I would like to have a single colour square (blue for example) and when the mouse touches the left or right side of the square it rotates horizontally, and if it touches the top or bottom, it rotates vertically. I would also like the other side of the square to be a different colour.

I'm sure this is possible, but I have no idea how to do it! Any help would be greatly appriciated.

Thanks

Rotating Squares
Hello.

I would like to create a square (in Flash MX), that rotates on it's X and Y axis when the mouse rolls over it.

Specifically, I would like to have a single colour square (blue for example) and when the mouse touches the left or right side of the square it rotates horizontally, and if it touches the top or bottom, it rotates vertically. I would also like the other side of the square to be a different colour.

I'm sure this is possible, but I have no idea how to do it! Any help would be greatly appriciated.

Thanks

Squares Animation
Hi. Can someone help me with an animation I'm working on?

Basically what I’m trying to do is make random20x20px squares appear and disappear with random values of alpha on top of an image. The time that they appear and disappear must be random too. Also the have to appear in random positions in the movie.

The stage is 504x86. Horizontally they can take this x values: 0, 22, 44, 66, 88, 110, 132, 154, 176, 198, 220, 242, 264, 286, 308, 330, 352, 374, 396, 418, 440, 462, 484. Vertically the can take this y values: 0, 22, 44, 66.

Squares Gets Stuck
just click on info or something else in the mnu and notice how the squares gets stucked. anybody know how to avoid this?

And if you get at code error message it's another problem. Dont care about that.

Popping Up Squares....
Hey all, anybody knows a tut or something where squares popup or fade in till a certain area is full? they should be right by each others side...and random, i've seen this effect very often out there, so it should be quite popular...

maybe someone has a link or hint or something

Cheers & Thx in advance

Pools Of Squares
I want to make a game with a effect similar to the Pool of Squares sample movie...

but I want when a "box" movieclip HitTest the Pool of squares then the squares will play.

I tryed using this code:

OnClipEvent(Load)
If _root.box HitTest(_.root.Square)
Telltarget (Square)
gotoAndPlay (2)

I have named all the squares the same name "Square"

Squares Gets Stuck
just click on info or something else in the mnu and notice how the squares gets stucked. anybody know how to avoid this?

And if you get at code error message it's another problem. Dont care about that.

Colour Squares
I have been asked to create a movie which looks simallar to a colour wall that you would see in a nightclub with the square changing through different colour schemes like this http://www.eyekiller.com/coloursq.gif

Has anyone see this done or know how to do this using Action Script?

Many thanks
Jamie

Need 100 Squares On Stage?
hi guys any ideas on how to:

put 100 mcs on the stage randomly 1 at a time placed and then remove 100 1 at atime randomly

big thanks to all who post

its killing me....

regards

Dissolving Squares Tutorial
Hi Chaps,

After looking at this tutorial:-

http://www.flashkit.com/movies/Effec...79/index.shtml

I am wondering whether there is a way to add an image over the top of the squares that dissolves with each square to give a scratchcard effect?

Any clues...?

cheers peeeeeple
SpaceyUK

Random Disapear Of Squares
Hello,

i have 30 squares in my site. I also have a function which fades out a MC. I want to fade the squares one by one in a random way.

for fading i use the command square01.fadeOut(speed, limit);

So how can i fade out the 30 squares in a random way?
i tryied a loop for and random command but i wasn't able.

Thanks,
Miguel

Random Colored Squares
Hi everyone, i dont know if this is the right forum where i should ask for help, just correct me if i wrong anyways i want to create a random colored squares as my transition for movie clips, like before i show movieclip2 i should play a transition first before showing it. The concept would be random colored sqaures moving around the scene like changing places or something. If you'll look at http://www.orangedesign.com when you click one of the window(ex. contact us) before you'll see other stuff a transition is being played, a randomed color squares which moves around, i think randomly also.

Any help or advise will surely be appreciated

Go To Scene After Counting All Squares
http://www.nadinagafoor.com/Portfolio.htm if you will go to this site you will see a menu button at top left, when u mouse over on it, you will see a menu comes and when you enter on Interactive option the many squares comes they When they all will disapear then next scene will start no matter which will be last i know their is counter which is counting the value of squares then after all its going for next scene, but i dont know how its possible please mail me answer or if you can arrange a small demo fla so it will really appreciable for me
i really want to learn how it possible.
Salman Lakhani
princelakhani@yahoo.com

Random Squares Fade Out
does anyone know whats wrong with my code?

code:
multiSq = [square0,square1,square2,square3,square4]
rNum = random (5);
for (i = 0; i < multiSq.length;++i){
square[rNum].ealpha = 0;
}


im trying to make squares romdomly fade out one by one untill they are all gone can anyone help me?

this is the code i have on the squares:

code:
onClipEvent(load){
_alpha = 100;
ealpha = 100;
speed = 5;
}
onClipEvent(enterFrame){
_alpha += (ealpha - _alpha)/speed;
}

Moving Line/Squares
Hello all.

I have a simple task. To make a blind effect with coloured lines/squares. I can't seem to get the hang of it.

Can someone point me in the direction of a tutorial? The best i can describe it, it there being a picture, and then coloured squares/lines going down it to cover it.

Thanks in advanced for your time

Random Squares Preloader
I'm having issues with this. I am making a preloader in which as it loads, random squares lose their visibility to reveal a picture. I have squares named "clownjewmask1" all the way up to 399. I had this written out and I'm trying to get it so that only squares randomly generated disappear. the "square" variable is a random number from 1 to 399. This is the only line I'm having trouble with:

["clownjewmask"+square]_visible = false;

PixelDissolve With Fading Squares?
Hi,

I am using PixelDissolve-transition on a movieclip. But i want the squares to fade in rather than just appear.

Is there an easy way to do this without making my own class that extends the PixelDissolve class?

Thanks!

Pulsating Grid Of Squares
I'm really having problems with an effect that I think is actually quite simple to do...

In this link:
http://www.vatmanagement.dk/pages/vat.html
I've illustrated what I'm going for. The top 'frame' holds an image over which a grid of squares is suppossed to softly fadein and out at random intervals. I hope the effect is understandable.

My problem is that I just don't know whether to duplicate and place square clips over and over OR place them from the start and somehow give them a random play timer or something. My AS knowledge is somewhat primitve so that's why I come to you guys, hoping for help.

I'm not neccesarily looking for a pure copy/paste script as I'd like to know what it is I'm pasting if you know what I mean...

ANY help is greatly appreciated here. I've searched all the forums I could find, but haven't found what I'm looking for...

Calculating Pixels In Squares
I have a math issue that I have some problems solving.

screen1
screen2

I need to calulate the pixels inside the squares and put them inside an array:

The main square rotates(see screen2) and i have the angle.

Something like attached code.

I have the following values:
- x/y of the main square. ( reference point )
- Width/height of the main square
- Width/height of all the squares
- Angle of main square..

Any ideas how the formular looks?

Thanks in advance!







Attach Code

var square1 : array = new array(150:102,150:103, 150:104,150:105) etc...
var square2 : array = new array(150:302,150:303, 150:304,150:305)etc...
var square3 : array = new array(300:302,300:303, 300:304,300:305)etc...
etc...

























Edited: 01/27/2009 at 07:18:07 AM by Lindestrøm

Random Moving Squares
Found this flash sample and i can't figure out how to do the random and continuous dancing squares.

I just think that its a random, continuously scrolling image

http://www.mix-fx.com/balancedshakecasual.htm

It's pretty similar to the link summary from kirupa.com found on top of each link page such as this:

http://www.kirupa.com/developer/flash5/home.htm

without the mouse cross

BTW, i'm using flash 5 right now

Pond Of Squares Into Another Movie
HI, I followed your tutoriaql for a pond of squares and I made an animation that I then tried to integrate as a background ofmy main navigation area.

this is what I did:
1) made the pond of squares animation and tested it, worked perfectly
2) imported the pond of squares animation as a movie clip symbol, I noticed that the tweens in the symbol turned into individual keyframes which was already kinda funny
3)I just places the symbol on an individual layer in my animatin and tested it

any idea of what Im missing?

will be so greateful to get some help


flash mx newbie

Squares Transition Effect
Trying to find a tutorial on how to create a transition effect for a slideshow where a series of squares/boxes appear to reveal an image, then transition to the next image in the same fashion. I know I've seen this many times, but can't find a tutorial for it. I guess I could create a series of square-shaped masks, but I was hoping to find something a little cooler that used actionscript to do most of the work. Any suggestions?

Thanks

Breaking Apart Bitmaps And Red Squares
sometimes to save time when im working with PNG's, i place multiple items in one png and break it apart for animation
99% of the time this works fine, but every now and then i find that a few of the tweens or mc's or whatever randomly turn into red squares - the bitmap fill has been replaced with just solid red and its unrecoverable

has anyone experienced this and figured out the cause?

Draw Two Squares And Drag One
Draw two squares and drag one

What i am doing is trying to create a draggable window.

Below is the code to draw and drag a square. This works!

Below that is the code that I put in the Flash to draw two squares.

That also works but here are two questions:

1. The code to draw two squares seems long winded. All i did was duplicate the first part. Can this be simplified?

2. The drag causes both squares to drag which is what i want but i only want the drag to work when applied to the top square and not to the other square.
Is this possible?

Thanks!



Code:
// import the Event dispatcher class (Step1)

import mx.events.EventDispatcher

class drawMeASquare{

var thebox_mc:MovieClip;
var thecolor:Number;
var thexpos:Number;
var theypos:Number;
var thewidth:Number;
var theheight:Number;

//declare the dispatchEvent, addEventListener and removeEventListener methods that EventDispatcher uses (Step2)


function dispatchEvent() {};
function addEventListener() {};
function removeEventListener() {};


function drawMeASquare(windowthecolor:Number, windowthexpos:Number,
windowtheypos:Number,windowthewidth:Number,windowtheheight:Number){

// send instance of self to the Event Dispatcher (Step3)

mx.events.EventDispatcher.initialize(this);


this.thecolor = windowthecolor;
this.thexpos = windowthexpos;
this.theypos = windowtheypos;
this.thewidth = windowthewidth;
this.theheight = windowtheheight;

}

function drawItNow(cliptoDrawin:MovieClip){ // I draw a thebox in any movie clip

cliptoDrawin.createEmptyMovieClip("thebox_mc", cliptoDrawin.getNextHighestDepth());

this.thebox_mc = cliptoDrawin.thebox_mc;
thebox_mc.beginFill(thecolor);//(0xFF0000);
thebox_mc.moveTo(thexpos, theypos);
thebox_mc.lineTo(thewidth, theypos);
thebox_mc.lineTo(thewidth, theheight);
thebox_mc.lineTo(thexpos, theheight);
thebox_mc.lineTo(thexpos, theypos);
thebox_mc.endFill();


//event handler, called when object is pressed (mouse button down)

thebox_mc.onPress=function(){

//begin a drag operation on the movie clip (handled by Flash automatically)
this.startDrag();
//store a flag stating we're dragging
this.dragging = true;
}

//event handler, called when object is released (mouse button up)

thebox_mc.onRelease=function(){
//stop dragging
this.stopDrag();
this.dragging = false;
}

//event handler, called when object is released (button up outside object)

thebox_mc.onReleaseOutside=function(){

//stop dragging if we're currently dragging
if(this.dragging) {
this.stopDrag();
this.dragging = false;
}
}

//define the event object that is passed to any listeners when the event is broadcast (Step4)
// You must specify a target property and then name of the event or the event “type” property in the event object

var eventObject:Object = {target:this, type:'drawn'};

// any optional properties

eventObject.drawObject = 'thebox';
eventObject.whereDrawn = cliptoDrawin.thebox_mc;

//dispatch the event (Step5)
dispatchEvent(eventObject);

}

}
////////////////////////////////////////////////////////////////


Code:

// new custom class object (must be new to run the constructor)
var mySquareObject:drawMeASquare = new drawMeASquare(0x0000FF,10,10,100,200);

// new object we can use for a listener
var myListnerObj:Object = new Object;

// method definition for the drawn event
myListnerObj.drawn = function(evtObj) {


// Now trace out a few things. At this point you know the square is drawn and anything you need from the square is available!


trace("The Square is drawn: ");
trace("This is the drawObject prop: "+ evtObj.drawObject);
trace("This is the whereDrawn prop: "+ evtObj.whereDrawn);
trace("This is the event type: "+ evtObj.type);
trace("This is the event target: "+ evtObj.target);
}

// subscribe myListnerObj to mySquareObject
mySquareObject.addEventListener("drawn",myListnerObj);

// draw the square and trigger the event:
mySquareObject.drawItNow(_root);

//////////////////////////////////////////////////////////

// new custom class object (must be new to run the constructor)
var mySquareObject:drawMeASquare = new drawMeASquare(0xff00FF,10,10,300,100);

// new object we can use for a listener
var myListnerObj:Object = new Object;

// method definition for the drawn event
myListnerObj.drawn = function(evtObj) {


// Now trace out a few things. At this point you know the square is drawn and anything you need from the square is available!


trace("The Square is drawn: ");
trace("This is the drawObject prop: "+ evtObj.drawObject);
trace("This is the whereDrawn prop: "+ evtObj.whereDrawn);
trace("This is the event type: "+ evtObj.type);
trace("This is the event target: "+ evtObj.target);
}

// subscribe myListnerObj to mySquareObject
mySquareObject.addEventListener("drawn",myListnerObj);

// draw the square and trigger the event:
mySquareObject.drawItNow(_root);

Black Squares When I Publish
Hey out there.
Using flash 8 publishing to player 7

The other day i updated my player to flash 9/something. Went back to a project and noticed my bitmaps were having moving black squares apprearing on them - not all just some.
So i republished to player 8 and they went bye bye.

Is this a glitch in the new player? Has anybody else had this trouble? It was suggested by a flashman that i publish to player 7 because there are more of those players on computers, but if publishing down to 7 gets me random black squares...

any help would be a help.
thanks

Hoss

Complex Colision Detection With Two 'non Squares'
Hi, I have been researching complex collision detection.

The complex detection that I have seen involves a movie clip, whose shape is used to detect a collision with a co-ordinate, be it a mouse or a center point.

I, however would like to use two curvy shapes, and detect if they touch.

Has anyone heard of this, or am I going to have to plot all the points around my shape and do a detection loop....

M@

Passing Variables And Creating Squares
I have a movie in which when you click, a line from the left and top tween to a random spot on the screen and creates 4 squares. I want to fill two of these squares when the lines stop moving. I published the file here:
http://galatea.stetson.edu/~ssabonjo/balance Is there any way I can do this? The two lines are movie clips that randomly pick a new x or y and tween to it. I also have a version where there is a large movieclip that is a crosshair that the whole movie tweens.

I appreciate any help.

Can't Draw Anchor Points On Squares
Usually it's no problem to add anchor points to a line with the pen tool.

But why doesn't it work if the line was originally made with the rectangle tool? I can't add anchor points to jpgs, etc. dragged from the library and broken into forms, either. Any ideas?!

Notepad Text Making Little Squares
I am importing a newsletter into a flash movie from a txt file...I have no charaters imported and _sans font picked... everything is fine except wherever there is a ' a little square appears on the page...I have tried many different fonts and it either gives me the square again or ignores it completly.... any suggestions?
g

Colliding Squares - (physics Related)
Alright. so i am using two images as MC's they bounce around on the stage as if there were balls. (with gravity and walls and all that). I want to have it though so that when they collide into eachother, they act correctly when they bounce off...

anyone coded this before?

heres what i have so far:
my confusion is in the checkCollide() function



Code:
/* NOTE:

@ two squares are named mhead and phead
@ phead starts off the stage and when a button is clicked
it is added
*/
YBOUND = 501;
XBOUND = 700;
bounce = .90;
xground = .6;
xbounce = .8;
ydamp = 1;
gravity = 1;
//---------------
mhead.vy = 0;
mhead.vx = 0;
mhead.onEnterFrame = move;
mhead.onPress = drag;
mhead.onRelease = drop;
//--------------
phead._x = 60+Math.random()*(XBOUND-30);
phead._y = 200;
phead.vy = 0;
phead.vx = 0;
phead.onEnterFrame = move;
phead.onPress = drag;
phead.onRelease = drop;
setInterval(checkCollide, 30);
stop();
function checkCollide()
{
if ((!phead.drag) && (!mhead.drag))
{
if (phead.hitTest(mhead))
{
xp = phead._x;
yp = phead._y;
xm = mhead._x;
ym = mhead._y;
theta = Math.atan2(yp-ym, xp-xm);
mhead.vy *= -Math.sin(theta);
phead.vy *= Math.sin(theta);
mhead.vx *= Math.cos(theta);
phead.vx *= -Math.sin(theta);
/*??????????????????????????????????
THIS IS WHERE I AM CONFUSED!!
??????????????????????????????????*/
//mhead._x = phead._x-(xside*mhead._width/2);
}
}
}
function move()
{
if (!this.drag)
{
this.vy = (this.vy+gravity)*ydamp;
//this.vx *= xdamp;
this._x += this.vx;
this._y += this.vy;
if (this._x<this._width/2)
{
this.vx *= -1*xbounce;
this._x = this._width/2;
} else if (this._x>XBOUND-this._width/2)
{
this.vx *= -1*xbounce;
this._x = XBOUND-this._width/2;
}
if (this._y>YBOUND-this._height/2)
{
this.vx *= xground;
this.vy *= -bounce;
this._y = YBOUND-this._height/2;
} else if (this._y<this._height/2)
{
this.vy *= -bounce;
this._y = this._height/2;
}
} else
{
this.vx = this._x-this.oldX;
this.vy = this._y-this.oldY;
this.oldX = this._x;
this.oldY = this._y;
}
}
function drag()
{
this.oldX = this._x;
this.oldY = this._y;
this.startDrag(true);
this.drag = true;
}
function drop()
{
this.stopDrag();
this.drag = false;
}

[F8] HitTest For Multiple Instances Of Squares?
What is the best way to create tens of squares that each can detect collisions with each other? Luckily I'm working with squares, so even I have created a hitTest that gets the desired movement in one direction (per collision).

But so far my code is only for two squares, and I'm working toward a grid of maybe 24-35 squares. Most of the squares disappear when a category is chosen, but 7-10 squares remain that grow to fit their now roomier surroundings. Each one would detect collisions with the others and react accordingly.

Searching, I've only found a reference to associative arrays, though it didn't elaborate. I will pursue it further if people think it's the way to go. What is the best format for this?

Here's my work so far within the hitTest. Mostly I'm looking to iterate this to create may of them. But please tell me if you know a better way to do hitTests or see somewhere I'm not using good practices, etc.

var difX = this._x - _root.block2._x;
var difY = this._y - _root.block2._y;

// are the squares more side-to-side than above-and-below?
if(Math.abs(difX) > Math.abs(difY)) {
if (this._x < _root.block2._x)this._x = this._x -_root.BUMPSPEED;
else this._x = this._x + _root.BUMPSPEED;
}
// if objects are more side-to-side
// if this one's left go more left
// else go right.

else{
if (this._y < _root.block2._y) this._y = this._y - _root.BUMPSPEED;
elsethis._y = this._y + _root.BUMPSPEED;
}
// otherwise go up or down

Copyright © 2005-08 www.BigResource.com, All rights reserved