# Typed Objects

**URL:** <https://forum.kirupa.com/t/typed-objects/329964>\
**Category:** flash\
**Created:** [November 12, 2012, 9:11pm UTC](https://forum.kirupa.com/t/typed-objects/329964 "2012-11-12T21:11:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![reppinfreedom](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@reppinfreedom](https://forum.kirupa.com/u/reppinfreedom)\
**Post date:** [November 12, 2012, 9:11pm UTC](https://forum.kirupa.com/t/typed-objects/329964/1 "2012-11-12T21:11:31Z")

</div>

Is there any way to create typed objects in AS3? I have had issues with non typed objects causing errors because of NaN and null I think…

Eg…

```php

var myObject:Object.<int> = new Object.<int>();
myObject.Row = 22;
myObject.Col = "14"; // Converts to number or NaN/Null, etc... Something that won't cause an error.
etc...

```

Both of these functions do the exact same thing in a optimal scenario, but the first causes errors when the rowCol.Row and rowCol.Col variables are non numeric.

```php

//This function has errors with bad rowCol inputs
        public static function rowColToPoint(rowCol:Object, tileSizeX:int, tileSizeY:int):Point {
            var xyPoint = new Point();
            xyPoint.x = (rowCol.Col - rowCol.Row) * ((tileSizeX / 2) + 1);
            xyPoint.y = (rowCol.Col + rowCol.Row) * (tileSizeY / 2);
            return xyPoint;
        }

//This function is stable and error free
        public static function rowColToPoint(rowCol:Object, tileSizeX:int, tileSizeY:int):Point {
            var xyPoint = new Point();
            xyPoint.x = (int(rowCol.Col) - int(rowCol.Row)) * ((tileSizeX / 2) + 1);
            xyPoint.y = (int(rowCol.Col) + int(rowCol.Row)) * (tileSizeY / 2);
            return xyPoint;
        }

//This function is stable and error free and the one I use
        public static function rowColToPoint(rowCol:Object, tileSizeX:int, tileSizeY:int):Point {
            var rowIn:int = rowCol.Row;
            var colIn:int = rowCol.Col;
            var xyPoint = new Point();
            xyPoint.x = (colIn - rowIn) * ((tileSizeX / 2) + 1);
            xyPoint.y = (colIn + rowIn) * (tileSizeY / 2);
            return xyPoint;
        }

```
