ActionScript 2.0 :: [flash Cs4] Arrays And Hittests Not Working?

Sep 2, 2010

My fish is swimming along and needs to catch the food and avoid the poison. I've attempted to create arrays for the food and the poison so they are randomly dropping down. I've also added a hittest but can't get it to work.

I'm not really happy with the randomisation of the array, there are too many instances appearing on screen and I'm not sure how to fix this. Is there an easier way to animate the food dropping down without using as2 and arrays? There is also something wrong with my score, each food should be +10 to score and poison should be -10, but that doesn't seem to be working either. I also don't know what script to type to end the game to either a congratualtions screen or game over screen. Basically I have no idea what I'm doing and haven't had much help from my teacher, he may as well be speaking another language.

View 2 Replies


Similar Posts:


ActionScript 3.0 :: How To Flash Working With Arrays

Jan 24, 2011

I finally decided to start learning about arrays in AS3 and i could use a I learned how to create an array and add references to movie clips in the library, next thing i want to learn is how i can add multiple instances of one movie clip to the stage without having to name each one and do the addChild thing.

View 5 Replies

ActionScript 2.0 :: Curved HitTests For Flash 2004 MX?

Aug 16, 2006

how do you make a curved/slanted hitTest?

View 1 Replies

Arrays :: Flash - Pushing Or Adding Arrays As Values Into A Multi-dimensional Array?

Jan 21, 2011

I am running into some trouble adding an array into another array to create a multi-dimensional array.The code appears as below:

var slideDataArray:Array = new Array();
var slideShowDataArray:Array = new Array();
slideDataArray[0] = xmlData.SlideShowParameters.SlideShowImagesDirectory;[code]........


I am looking for a means of placing the slideDataArray into a 'slot' or value of slideShowDataArray so that I can in the end pass the slideShowDataArray as a parameter to another function.As of now, the last slideDataArray appears 11 times (the loop runs 11 times) in slideShowDataArray and the way the code is written the slideDataArray is unique every iteration of the loop.

View 1 Replies

ActionScript 3.0 :: Arrays And Conditionals Not Working?

Feb 8, 2010

I'm working with CS4 and AS3 using timeline coding. I have three sets of movie clips in three different arrays. The idea is to have topArray and downArray movies make zeroArray movies visible. For instance, if topArray[0] and downArray[0] are clicked, then r0_0 becomes visible. PROBLEM: r0_0 becomes visible when EITHER topArray or downArray is clicked. How to make r0_0 wait until BOTH top and downArray movies are clicked?

[Code]...

View 5 Replies

Actionscript :: Arrays - Collision Not Working

May 10, 2011

I'm making a game and ran into a problem I've been unable to figure out. The player is a boat, the boat can drop mines (via space key). I've created a Mine() Array in the init():

[Code]...

View 1 Replies

Arrays :: Flex DropDown Selection Not Working When Search For Item?

Nov 26, 2011

so here is the problem that I have so far. I tried to simplify my code so I can attempt to figure this out, but I have had absolutely no luck. I have a viewstack that contains 1 dropdown per stack. They share the same data provider. What I want to do is to select the item contents from the first one. Once I do that, when I click a button to the next stack I have a function that searches from index 0 to the dataprovider length and if the item from the first stack matches the second one, I want to have the second dropdown pick that item up and display it. I have it matching, and I try to select it, but when I run the application it shows up like nothing is selected. Here is what I have:

edit: I got it to work for a simple example, but when I attempt to use it in my more complicated example, on that button click it for some reason resets the value of selectedIndex to -1. How do I prevent this from happening? This is working code for the simple example

[Code]...

View 1 Replies

ActionScript 1/2 :: Hittests For Mcs Inside Other Mcs?

Aug 5, 2010

I have a hittest code that's supposed to prevent an mc from moving into a space occupied by another mc. The thing is, the first mc is inside another mc and for some reason the hittest isn't registering. The code I'm using is below. Is it wrong somehow, or is there another code I should be using?
 
Key.addListener(keyListener);
this.onEnterFrame=loopF;
function loopF() {

[code]...

View 3 Replies

ActionScript 2.0 :: Having Multiple HitTests With Same Movieclip?

Apr 29, 2010

I'm currently programming in AS 2.0, and I'm trying to get a piece of code to work. I have a movieclip that is deployed when the user clicks a mouse button, sort of like a bombshell being dropped on an area.

However, when I run it, it's quite obviously only registering one of the hitTests, because _parent.sprite_counter only decrements by one, regardless of how many enemies are destroyed. That's the other weird thing; no matter what, even if the counter never decrements, the movieclip still is removed.

Is it because you've got several movieclips simultaneously trying to decrement the same variable?

View 2 Replies

ActionScript 1/2 :: HitTests Dont Work ?

Aug 7, 2011

Ive got this script. when u press a button u can create a movie clip called man. when u press another button u can create one called enemy. thay both create at different sides of the seane and thay walk past each other.but when thay touch each other thay should go to frames inside them. ect Attack,Die.

var mans = 0;
function addman() {
if (Gold>=10) { [code]....

View 4 Replies

ActionScript 2.0 :: Looping Through Multiple Hittests

Dec 5, 2009

I have many, potentially hundreds, of objects that are floating around the screen. These objects are named "Object1", "Object2", "Object3" and so on. Another object is moving around the screen and if it hits any of the other objects, it destroys them. The thing is, if I have a loop like:

Code:
for(var i = 0; i < ObjectCount; i++)

where ObjectCount is subtracted off each time an Object is destroyed. Now say Object1 is removed, then the loop will fall short and not check for a collision for the Object with the highest number. The way I am dealing with this at the moment is I am looping through the initial number of objects and not subtracting off ObjectCount, so when there is only say 10 of an inital 100 objects left, it is still looping through all 100.

Here is what the principle of it is:

Code:
for(var i = 0; i < ObjectCount; i++)
{
CurrentObject = GameArea["Object"+i];

[Code]......

And as you can see, if Object1 is removed, then the Object with the highest number on it will not be checked.

View 3 Replies

ActionScript 2.0 :: Mx2004 Multiple HitTests

Sep 14, 2004

I have 9 static movieclips arranged in a 3 by 3 grid, and 1 movieclip that moves using keypresses (invisible_mc)[code]when a hitTest is registered between the invisible_mc and any of the icon_mc's, The icon_mc goes to and stops on frame 2..else it goes to and stops on frame 1. I have constructed the hitTest as follows.is there anyway to reduce the endless repetition of code? [coe]

View 1 Replies

ActionScript 2.0 :: HitTests On Multiple Objects?

Apr 9, 2005

I have a bullet movieclip and it moves. I've put a hitTest on its onEnterFrame so that it checks if it hits its target, whose instance name is mmbug and the target flies around. That's easy and works cool.[URL]there's only one wasp present at a time and it works)Now what I want to do is duplicate the wasps so there are more flying around at one time, but how would I do the hitTest on the bullet then, because you have to specify it an exact instance name. If I make all the wasps have the same instance names it doesn't work.So obviously I'd have to give them names of mmbug1, mmbug2, mmbug3 etc. But how would I check on the hitTest if it hits any of them, since you have to put in an exact instance name in the hitTest?

View 5 Replies

ActionScript 3.0 :: How To Handle Multiple Hittests

May 24, 2009

I've been reading up and looking at examples of how to handle multiple hittests. So far in my example I have failed.

[Code].....

Basically I want to be able to check for a hitTest against all the bullets on stage against all atoms created. I attempted to do this with two for loops and it didn't work

View 4 Replies

ActionScript 2.0 :: HitTests On Multiple Objects

Apr 9, 2005

For instance, I have a bullet movieclip and it moves. I've put a hitTest on its onEnterFrame so that it checks if it hits its target, whose instance name is mmbug and the target flies around. That's easy and works cool. ( see [URL] , there's only one wasp present at a time and it works) Now what I want to do is duplicate the wasps so there are more flying around at one time, but how would I do the hitTest on the bullet then, because you have to specify it an exact instance name. If I make all the wasps have the same instance names it doesn't work. So obviously I'd have to give them names of mmbug1, mmbug2, mmbug3 etc. But how would I check on the hitTest if it hits any of them, since you have to put in an exact instance name in the hitTest?

View 5 Replies

Professional :: Create Multiple Enemies And Be Able To Do HitTests Against Them?

Oct 12, 2010

i got this flash with duplicated mc's say...enemy1, enemy2, enemy3. now we all know we can do something such as..
 
if {_root.blah.hitTests(_root.enemy)){_root.enemy.nextFrame();}}
 
because the enemy is duplicated and its no longer "enemy" but enemy12 or ****.is there any way to ...create multiple enemies and be able to do hitTests against them somehow.Also im not really a fan of attachMC

View 5 Replies

ActionScript 2.0 :: Movie Clip Hittests Anything On The Screen?

Jun 15, 2007

Is it possible to check if a movie clip hittests anything on the screen?

View 1 Replies

ActionScript 2.0 :: Duplicating Movie Clips, Loops And HitTests?

Mar 18, 2010

I'm creating a simple game called shape wars. The game is shooting game where a blue cube(the player) fires blue shapes at the enemy(the red cube). The red cube also fires red shapes at the blue cube.Here is my code for duplicating the red shapes (this code is contained within the enemy)

onClipEvent (enterFrame) {
//attack
att = random(6);
if (att == 1 && dead == false) {
_root.redBullets++;

[code]....

View 2 Replies

ActionScript 1/2 :: If Multiple Hittests Equal True, Go To And Play Next Frame?

Dec 7, 2009

I am trying to finish up a project and run into this problem, right now I am trying to create a drag and drop game and on the last game you can dropparts into the others, what I want to happen is that when all are in the correct spot gotoandplay next frame. This is my current code,

if(one_mc._droptarget=="/onedef_mc" && two_mc._droptarget=="/twodef_mc" && three_mc._droptarget=="/threedef_mc" && four_mc._droptarget=="/fourdef_mc" && five_mc._droptarget=="/fivedef_mc" && six_mc._droptarget=="/sixdef_mc" &&

[code]....

View 9 Replies

ActionScript 3.0 :: Arrays Of Arrays / Data Providers And Dictionarys

Aug 26, 2009

I've got a bit that loads a big chunk of xml data about products.I push product info into an array(e.g. productArray), then add that array to another array (e.g. allProductsArray)How do I sort those arrays? For instance, if I want to sort the allProductsArray based on the info in productArray[0]?Alternatively, would something other tha an array of arrays be a better route?This loader loads the same sort of info for many different clients, so the bit to sort on will change.

View 5 Replies

Arrays :: Fastest Way To Merge Multiple Arrays?

Sep 26, 2011

I'm trying to write a function where I can specify any amount of array, and the return value will be an array containing the contents of all of the specified arrays.I've done this, but it seems like a really slow and ugly way of doing it:

var ar1:Array = [1,2,3,4,5,6,7,8,9];
var ar2:Array = ['a','b','c','d','e','f','g','h'];
function merge(...multi):Array[code].....

Is there an inbuilt and more efficient / nice way of achieving this? The result does not need to be in the same order as the input - completely unsorted is fine.

View 3 Replies

ActionScript 3.0 :: Randomizing The World! Arrays And More Arrays?

Feb 17, 2009

A little explanation: Im making a random arranging number Array. So instead of using a loop and assigning 0 to first array element, 1 to second, etc.I need to make it totally random but without repeating any numbers. To do that I made a second Array that will have the same number of children to serve as a reference.Each of them will be an Object with a property "num" , wich will be its actual number, and a property "called" wich defaults to false.Like this:

ActionScript Code:
for(var i:int=0;i<vQuantity;i++){
ranArray.push( new Object() );

[code].......

View 8 Replies

ActionScript 3.0 :: Arrays Store References Of Other Arrays?

Dec 27, 2009

I've had a problem for awhile that was really odd. After some intense debugging, I realized the problem lied in setting an array equal to another array.[code] When setting one array equal to another, the values aren't copied over, but a reference to that memory is stored. So no matter which variable you change, they are both references to the same memory and thus both will reflect the changes.With other data types, this doesn't happen.I could fix it by looping through t1 and using push() to add each index from t1 into t2, but that seems a little messy.

View 7 Replies

ActionScript 2.0 :: Pushing Variables To Arrays Within Arrays?

Jun 25, 2004

correct syntax for pushing variables to arrays within arrays? I have searched many threads but found nothing that exactly answers my query.I have a class (Brigade) which amongst other variables contains an array (BrigadeUnits) This is the third element.. My Brigades are stored in an array called AllBrigades. I now need to fill the BrigadeUnits array with objects of my Units class.The hierarchy I want to create is as follows:

AllBrigades (array of Brigades)
Brigade (object)
BrigadeUnits (array within Brigade object)
Unit (Object to be stored in BrigadeUnits array)

I have tried various approaches including the following, assuming that I am addressing the first Brigade in the array:

AllBrigades [0] [2].push (MyUnit);

But when I trace this I just get undefined.

View 14 Replies

IDE :: Movieclip HitTests On Particular Layers Of A Movieclip?

Mar 19, 2010

I'm working on a game project for school and I'd like to cut down the amount of library items I'm going to have to make for each level (I have a clip for unwalkable areas, places where shots can impact and so on.) Is there a way I can just draw one movieclip per level and cut up its parts into different layers, then call hittests on just specific layers instead of the whole movieclip?

View 3 Replies

Flash :: Working Fine In Local System ... Not Working In The Live Site

Nov 5, 2009

I have a flash project, its working fine in local system, but the same file is not working in live here is the link of the site, its showing blank page, the flash contents are not loading... [URL]

View 12 Replies

Flash Working Fine In Local System / Not Working In Live Site

Dec 14, 2009

I have a flash project, its working fine in local system and checked this file with uploading in someother websites, its working fine there too, but the same file is not working in live here is the link of the site, its showing blank page, the flash contents are not loading.URL...and here the same file which i have uploaded it in other server its working fine.URL...

View 2 Replies

Actionscript 3 - Flash Player Is Not Working In Domain / But Working If I Provided IP

Oct 14, 2010

I have developed a player in AS3. It is working if i provide the IP of the website. But, it is not working when i provide the full domain name. Even, i provide the crossdomain.xml for global access.

View 1 Replies

ActionScript 3.0 :: Flash - Url Picking Not Working On Server But Working Locally

Mar 17, 2012

i have a "swf" file which is picking url from xml & displaying the image, when i tested it locally it works fine, which means it picks up URL from XML & displaying corresponding image. After i uploaded it on server, it doesn't show anything.

View 2 Replies

Flex :: 9scalling Is Not Working At Runtime (although Working In Flash)?

Jul 10, 2010

I created a 9-scalled background in Flash CS5 which is working fine in Flash CS5.But when i imported it as embeded graphic in Flex, and change dimensions in runtime, 9-scalling doesnt work.Here is my code.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"[code]....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved