actionscript-3,collision,flixel , FlxG.collide (with setTileProperties) colliding outside the tile space in flixel


FlxG.collide (with setTileProperties) colliding outside the tile space in flixel

Question:

Tag: actionscript-3,collision,flixel

so I have been using flixel I some recently, and I think I am getting a feel for it, but I have come across a issue.

I have a Map class, that uses the loadMap() function, which comes out great.

I then use setTileProperties() on my Water tile, that then calls a function, calls a Boolean on my player class (to say that he is in the water), which then slows him down. This still works great, except for one thing. When I pass the water tile above or to the right (about 10-16ish pixels, haven't gotten the exact number) outside the tile, it still slows the player. I am not sure if this is just the way that FlxG.collide() works, or if there is something I can do to fix it, or maybe if I should find another way to use the collision. All help is appreciated.

Here is the code, if you need it:

Map.as

   private function createMap():void {
            loadMap(new currentMap, currentTiles, 32, 32, 0, 0, 0);
            setTileProperties(4, FlxObject.NONE, PlayerInWater);                
        }
override public function update():void {
        super.update();
        FlxG.collide(Registry.player, this);

    }

    private function PlayerInWater(tile:FlxTile, player:Player):void {
        Registry.player.inWater = true;
        trace("player is in the water"); 

    }

Answer:

So, I have figured out an answer to this, for all of you who want to know. I used the overlapsPoint() method to create this:

private function createMap():void {
        //load Map
        loadMap(new currentMap, currentTiles, 32, 32, 0, 0, 0);
        //set water tiles
        setTileProperties(4, FlxObject.NONE);
        //put all of the water tiles in an array
        waterArray = getTileCoords(4);
    }

override public function update():void {
        super.update();
        //collision with map
        FlxG.collide(Registry.player, this);
        //loops through each water tile
        for each(var waterTile:FlxPoint in waterArray) {
            //checks if the player is overlapping the water tile
            if (Registry.player.overlapsPoint(waterTile)) {
                //if so, then the player is in water
                Registry.player.inWater = true;
            }
        }
    }

This method being so simple, it kind of makes me feel stupid for getting stuck on it, but if someone finds a more efficient method, please, go ahead and comment, or make a new answer. I always appreciate feedback.


Related:


AS3: Fast hovering doesn't execute rollOut


actionscript-3,flash,button
I'm having a serious problem that is getting me nervous: I've made a button _btn that includes ROLLOVER and ROLLOUT animations with coding (an nested movieclip instance called barra that increases to half alpha when you hover over and decreases when you hover out). [Here it should go a descriptive...

Create temporary rows in mysql


php,actionscript-3
Well, I want to do a Flash AS3 Chat. When the user send a message, the message will be created as a row in mysql with PHP, but if it be so, the mysql server will be very busy, then the row must be temporary. Someone can help me? ^^'...

Dynamic Text doesn't show up through code


actionscript-3
if I make a dynamic text on the stage, name it something like "output" And I write in the enterframe. output.text = "Something"; It doesn't even show up in the stage, and the text box is blank....

Remove click after going to another scene in AS3?


actionscript-3,flash
After switching to my 2nd scene, the keyboard event does not work until I left-click the screen. How to avoid that left click so that I can trigger my keyboard event directly right after moving to my 2nd scene? More details you may need: 1st Scene btnStart.addEventListener(MouseEvent.CLICK, initGame); function initGame(e:MouseEvent)...

converting XML data into an array of objects AS3


actionscript-3
I'm using Flash AS4 and Ive created and array that holds xml data which works fine with the following loop for(var i:int = 0; i < uNavXML.length(); i++){ navArray.push(uNavXML..navRef.text()[i]); The XML data is actually the names of movie clips that I have on stage: xmlLIST :<uNav> <unavNavID>1</unavNavID> <navRef>navBtns.nav01</navRef> </uNav> <uNav>...

Including library in AIR Native Extension causes the error, “The extension context does not have a method with the name…” for all methods


c++,c,actionscript-3,dll,air
I am working on an AIR Native Extension (ANE) for Windows desktop. The point of this extension is to be able to call out to a third-party C library, which consists of two .h files defining the method signatures/typedefs, and a .lib file. Before including the third party library in...

AS3 Dynamic variable naming


actionscript-3,flash,variables,dynamic
Is dynamic variable naming like this possible in ActionScript 3? for (var xz=0;xz<10;xz++){ var this['name' + xz]:Number = xz; } ...

AS3 - removeChild thinks it's working, but isn't removing anything (no error)


arrays,actionscript-3,removechild
This is similar to a question I asked a couple of weeks ago, but different code and previous solution is not working. In a nutshell, I'm creating an array of tiles, the size of which can be selected via a dropdown menu. I want the previous grid to be removed...

AS3 - Score counter


actionscript-3
I am making a simple math game with four frames. In the first frame you can choose the math operation you want to practice. In the second frame you are presented with a randomly generated math question. If you enter the correct answer, the application outputs "correct answer", and skips...

How to check collision if only bottom half of the sprite matters (think of a cherry with a stem)


swift,sprite,collision,rect
I am trying to put together a game using SpriteKit, in Swift. I have a moving sprite which is a rectangle of width (sprite.frame.size.width) and height 2*(sprite.frame.size.width) I only want to check collision of the bottom half which is a square of width (sprite.frame.size.width) and height (sprite.frame.size.width) I set sprite.anchorPoint...

How can hitTestObject work for many objects?


actionscript-3,hittest
I have a game where player moves forward over (semi)random tiles. I want a hittest for when the player hits a certain tile. However when the char hits one of the spawned in floor2's nothing happens. I think this is because there are multiple 'floor2' movieclips on the stage ?...

Adobe Flash CS6 AS3: KeyUp Handler triggers immediately after KeyDown Handler


actionscript-3,flash
So in my code I was attempting to make it where you had two players, each player had their own key down and key up handlers, clearly labelled in my attached code, and in their I handle the movement, player one has WSAD and player two uses the Left, Right,...

How to know fast if another computer is accesible in AS3 (Adobe Air)


file,actionscript-3,air,lan
I'm using FileStream to read files in two computers that are connected in a Local Area Network (LAN). I have no problem to read the files when the others computers are connected. I'm checking if the directory exists before writing the file I'm checking if the directory AND the file...

Edit Manager activePoint “Y” Position ActionScript3


actionscript-3,flash,text
I'm working with TextFlow and EditManager in AS3 (flashx.textLayout) I want to know how get ActivePosition pointer "Y" position, I know I can get activePosition from EditManager but it's returns character position. I want to count if activePosition out of screen, then scroll down (text is larger and its out...

AS3 LocalConnection: function is not firing


actionscript-3,flash,air
I'm building an AIR app that sends text string to a swf-file. When I export the sender and reciever apps to swf and run them in Flash players, everything works well. But when publishing the sender app to AIR things don't work anymore. I think the connection works, because there...

Actionscript 3 Search for string in array, propblem


arrays,actionscript-3,flash,actionscript
I have a problem with searching for strings in an array. I want to search for one word and if it exists, I want to trace the position of the string in the array. I believe it should be something like this: if (myArray contains "11111111") { trace("*position*") } else...

Fisher-Yates Shuffle Algorithm error


arrays,algorithm,actionscript-3,for-loop
so I'm currently making a quiz game with Actionscript 3.0, and I wanna shuffle the questions with this Fisher-Yates Shuffle Algorithm: This is my code: var questions:Array = [1,2,3,4,5,6,7,8,9,10]; function ShuffleArray(input:Array) { for (var i:int=input.length-1; i>=0; i--) { var randomIndex:int = Math.floor(Math.random() * (i+1)); var itemAtIndex:int = input[randomIndex]; input[randomIndex] =...

Two ane file conflict in one flex mobile application


android,ios,actionscript-3,flex,air-native-extension
I have two ane file for video recorder. One is for android and another is for ios device. Both have different package name and methods. Now, i import both Native Extension in single project. And detect ios and android device following way: if(Capabilities.version.indexOf('IOS') > -1) //for ios device And if(Capabilities.version.indexOf('AND')...

AS3 - Error #1056: Cannot create property 0 on Boolean


arrays,actionscript-3,boolean
I'm in need of creating multiple dynamic arrays and seem to have found exactly what I need at https://jadendreamer.wordpress.com/2012/05/06/flash-as3-tutorial-how-to-create-2d-or-3d-dynamic-multi-dimensional-arrays/ Example 1: var multiDimensionalArray:Array = new Array(); var boolArray:Array; var MAX_ROWS = 5; var MAX_COLS = 5; //initalize the arrays for (var row = 0; row <= MAX_ROWS; row++) { boolArray...

Error #1502: A script has executed for longer than the default time period of 15 seconds


actionscript-3,flash
this is my first time using AS3 so I apologise if the cause of this problem is painfully obvious. I'm making chess and I've got a class for each piece on the board. When it's player 1's turn, all the black pieces should wait to be clicked, but when I...

How to convert preg_replace from PHP to AS3?


php,actionscript-3
I'm doing a fan Transformice map editor, but I've a question, "How can I do a preg_replace in Flash AS3?"... This is something like <? $mapXml = "<C><P /><Z><S><S L="304" H="65" X="175" Y="355" T="6" P="0,0,0.3,0.2,0,0,0,0" /></S><D /><O /></Z></C>"; $mapXmlDisplay = preg_replace('<S L="(.*)" H="(.*), etc..."', 'someThing', $mapXml); ?> It's possible? Thanks...

ActionScript: How to listen for an event from a different XML


actionscript-3,events,flash-builder,mxml
I have a popup screen in which the player enters their name and clicks OK. When OK is clicked I want the player's name to be passed to the main XML. How can I do this? Here is the function in the main XML that handles the popup: private function...

Flash AS3 Crashing After A Multiple Clicks - Argument Error - noSource error


actionscript-3,flash,arguments,kiosk
I have here, some AS3 that is used to create a 19 button interactive kiosk. It calls 20 different video_files to be played in an FLVPLayer. When one button is clicked, it draws the player and specifies the source. Whats happening is on our PC, is our crazy-kid-test, where we...

AS3 - How do you call previous currentTarget from within a different event?


actionscript-3,events
I have a dropdown menu that lets you select an item to be placed on the stage. The item is drag and droppable so I use event.currentTarget.startDrag(); to start the drag. Ok, everything works fine so far. However, I also need to be able to rotate the item while it...

Flash CS6 / AS3: Drag and Resize a rectangle movieclip


actionscript-3,flash,resizable
Not sure if this is possible but going to ask: is there a way of being able to resize a symbol (in this case, a movie clip) in an swf file by clicking and dragging it with your cursor? One of the things I need to do is have a...

Can't parse XML AS3 in flash with namespaces [SOLVED]


xml,actionscript-3,flash,e4x
I don't understand why I can't parse these datas : <places yahoo:start="0" yahoo:count="1" yahoo:total="1" xmlns="http://where.yahooapis.com/v1/schema.rng" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"> <place yahoo:uri="http://where.yahooapis.com/v1/place/23424819" aaa:lang="en-US" xmlns:aaa="http://www.w3.org/XML/1998/namespace"> <woeid>23424819</woeid> <placeTypeName code="12">Pays</placeTypeName> <name>France</name> <country type="Pays" code="FR"...

Compile actionscript to a swf


actionscript-3,flash
I have a folder which is full of .as files, theres one .as file who is the "main" which has a ui (buttons) etc. i need to compile all into a swf file, or a way to debug it. these are the files: https://github.com/amitp/mapgen2 I have like 3 days trying...

Why isn't this php math code working


php,actionscript-3
Hey guy's so am trying to convert this as3 code to php but its not working correctly i need it like the as3 one generating thanks! PHP: print(floor(rand() * 1000) + 3000); Result:28240000 AS3: var intCID = Math.floor(Math.random() * 1000) + 3000; var strSessionId = String(intCID); trace(strSessionId); Result:3330...

AS3 Check if no object in an array is being hitTested


arrays,actionscript-3,flash
I have an array of platforms that I'm hitTesting against a player. I also have a boolean variable called onGround that is attached to the player. I need to be able to toggle onGround based on whether or not the player is hitting a platform in the array. It's been...

Is there a class in AS3 that tells you the type of the URL protocol?


actionscript-3,flex,flex4
Is there a class in AS3 or Flex that tells you the type of protocol a URI or URL is part of? I was sure there was a class that broke a URL into various parts and grouped it into usable data. For example, if the URL is, "mailTo" it...

Custom slider AS3 sound seek


javascript,jquery,actionscript-3,flash
i made a custom slider and everything seems to be fine, but I am trying to create a seek function to make the slider move using this.mySlider.sliderTrack.mouseX position from width:1000px I just need help figuring out how the math to make mouseX the new channel.position var newPercent = this.mySlider.sliderTrack.mouseX =...

AS3 can't find the load method on a Loader


actionscript-3,flash,flex
I'm trying to load an image from the internet with AS3 following this tutorial. When I try to compile the application I get the following error: Call a possibly undefined method load through a reference with static type Loader. my_loader.load(where, loaderContext); ^ Here is the code I'm using: package {...

Building a digital signage platform in HTML5


jquery,html5,actionscript-3
I need some feedback! So if any help, Thank you! I'm a developer for a digital signage company. We built a platform in Flash (ActionScript 3) and it has been running really smooth for a few years now. We've been talking about trying to move to HTML5, JQUERY and PHP...

SCORM API wrapper and Flash in full screen


javascript,actionscript-3,flash,scorm2004,scorm1.2
I lately posted this and unfortunately I couldn't figure it out why. Furthermore I haven't any solution for that. Today I realised I can switch between NORMAL and FULL_SCREEN without SCORM parts of the content (connect/disconnect, get/set, etc.). But when I check both Flash wrapper and Mike Rustici's edited API...

A movie clip above a simple button makes it unresponsive


actionscript-3,user-interface,flash
I have designed a menu in Flash CC which consists of several cloned buttons and an MC containing the text that is supposed to stay above the buttons. Each time a user switches the menu's page, AS commands the clip to switch to appropriate frames, therefore changing the text above...

Unity3D Play sound from particle


audio,unity3d,collision,particles
I am trying to play a sound when a particle collides with a wall. Right now, it just plays the sound from the parent object, which is the player. However, I want the sound to play from the particle. Which means when a particle is far to the left, you...

Activerecord Rails 4 perform something like a join that still returns rows that don't have the association


actionscript-3,ruby-on-rails-4,join,left-join
If after reading my question you have a suggestion for a better title, please add a comment. I was having trouble succinctly saying what I wanted. I have a situation like this. class Artist < ActiveRecord::Base has_many :album_artists has_many :albums, :through => :album_artists end class Album < ActiveRecord::Base has_many :album_artists...

action script 3 whole number as a division output


actionscript-3
hello, I want to get whole number after division. x = 3/2; //results x = 1 and not 1.5 how to do this in as3??...

how to zoom stage to rectangle area in as3 (Action Scripts 3)?


actionscript-3,flash
how to zoom stage to rectangle area in as3 (Action Scripts 3)? i have a text, when mouse over the ever word, color changed. now, when click the word i need to zoom to this word and hide the other word?...

How to separate Button Click and Fire Click?


actionscript-3
I have a button that starts the game, it initializes the game when you click it startButton.addEventListener(MouseEvent.CLICK, onStartButtonClick); I also have a firing thing, it's supposed to shoot AFTER you start the game by clicking the start button and THEN shoot when you click. stage.addEventListener(MouseEvent.CLICK, fire); However, it fires right...

how to fix error 1009 in as3


actionscript-3,timer,typeerror
hi i have been searhing the net for hours and have not found a solution to my problem and i have no idea how to fix it as i am only new to flash so if you know anything that might help me just comment below please all help is...

AS3 : How to compare 2 array containing objects using 1 for loop only?


arrays,actionscript-3,flash
I have 2 array having objects of different length var arr : Array = [{name : "aa", id : "0"}, {name : "bb", id : "1"}, {name : "cc", id : "2"}]; var arrTemp : Array = [{name : "ee", id : "0"}, {name : "hh", id : "1"}, {name...

How can i get a function to use any movie clip?


function,actionscript-3,flash-cs6
I'm a little lost in understanding this kind of function, i get the feeling this has been asked a thousand times but cannot find an explanation of what the code is doing. Basically i just want a movie clip with instance name box to do something, then reuse the function...

Get dispatchEvent data as a result


actionscript-3,flex,actionscript,flex4.6
Here i am working on native extension in which i send/dispatch data in the dataevent like: public static const PASSING_VIDEO_URL : String = "PASSING_URL"; dispatchEvent( new DataEvent( PASSING_URL,true,false,level) ); Now on eventlistener cd.addEventListener( CD.PASSING_URL, onURL ); protected function onURL(event:Event):void { txtUrl.text = event.data; txtUrl.text = event.text; } I got that...

How make with AS3 downloading MP3 files in the background mode and plays it?


actionscript-3,flash
I need help with AS3 make downloading MP3 files in the background mode. Man goes to my site and it will automatically load MP3 file on his computer and plays it. I read these examples here http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html but do not know how to do it? Prompt what code and how...

How to remove all Objects in For Loop?


actionscript-3,for-loop,flash-cs6
Hey Everyone So I know this has to be really Simple I am over complicating it and can't figure out how to do it. So I have these stars moving in the background in my startScreen and I want to remove them when the Game starts. Here is How I...

type conversion if flex


java,actionscript-3,flex
I am using Flerry as Java-Flex bridge for my Flex Desktop Application. How to convert List in Java to ArrayCollection in Flex Flex Code:- [Bindable]public var screenList:ArrayCollection; <flerry:NativeObject id="windowControllerObj" source="ls.window.EnumAllWindowNames" singleton="true" fault="windowControllerObj_faultHandler(event)"> <flerry:NativeMethod id="getWindowNames" name="getAllWindowNames" result="windowControllerObj_resultHandler(event)" fault="getWindowNames_faultHandler(event)"/>...

Find and replace in an AS3 String


string,actionscript-3,replace,find
I want to find the "(*" string in another string and then replace it with the < and / one but the method replace() can not do it. Sorry, but I can not write the string in the description together :D Here is my code: //Call the method like.. trace(searchandreplace("(*Foo)"));...

AS3-What's the difference between “rotation” and “rotationZ”?


actionscript-3
Both of them, do the same. so, are they completely same as each other or there is difference?

ActionScript: Specification of the is operator


actionscript-3
I am having trouble googling for the expected behavior of the is operator in AS3. What I need to know is what should happen if the left side is null. I know it is possible to test, and get empirical results, but I need to know what the specification says,...