Recent posts by MewMewwer1 on Kongregate

Flag Post

Topic: Game Programming / Help!: int. can't be null

I’m afraid that didn’t cut it. Still the same.
Thanks for the help anyway :3

 
Flag Post

Topic: Game Programming / Help!: int. can't be null

Dear Kongregate community.

This might seem like a stupid question, but it really isn’t. I know that integers can’t be null, but fixing it is somewhat of a problem.

Currently I’m trying to make a function that converts the numbers in a textfield to integers, which I managed to do.

Here is the code:

xtimes.addEventListener(TextEvent.TEXT_INPUT, textInput, false, 0, true);

function textInput(event:TextEvent):void
{
if(xtimes.length = 0) {
var times = 0 ;
trace(times);
} else {
var times = int(xtimes.text) ;
trace(times);
}
}

This code fixes the error, however somehow flash removes the first number fromt the textfield

(For instance: 1 becomes 0 11 becomes 1 111 becomes 11 etc.)

Any help would be appreciated.

P.S. I wish to thank the people that helped me out before, I managed to fix it by not using the point.touch listener but a regular mouse.click listener. I suppose that’ll have to do for now…

 
Flag Post

Topic: Game Programming / Creating an app for android: Where did i go wrong?

I figured it out: I try to set the integer to whatever is inside of the text field.
However: An integer cannot be null, and if there is nothing in the textfield, it IS null.

Solution:

if textfield.text > 0 then{
var times = parseInt((e.target as TextField).text);
}

I think that works, haven’t tried it out yet.
Could anyone confirm that?

 
Flag Post

Topic: Game Programming / Creating an app for android: Where did i go wrong?

Ok, the problem seems to be this:

var times = int((e.target as TextField).text);

And I’m sure it’s the var times, but i have defined this in this script as:

var times:Number = 1

I suppose I’ve done something wrong with making vars. That would explain why none of my buttons are working either.

EDIT: Wow, that was stupid. Semicolon anyone?
EDIT2: Well, that didn’t fix it. Times is still undefined. Which is odd…

 
Flag Post

Topic: Game Programming / Creating an app for android: Where did i go wrong?

Does that mean that i’m missing some imports?
I suppose so. Could anyone please take a look at it?

EDIT: Updated code new .as http://snipsave.com/user/redstuf

EDIT: It is indeed a problem with importing, because running this script dry (With only the textfield on the screen) results in the same error.

 
Flag Post

Topic: Game Programming / Creating an app for android: Where did i go wrong?

Thanks a lot, that seems to work.

But when i try to edit the text box, it gives me this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at main/textInput()[main::frame1:31]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.controls::TextInput/handleTextInput()

 
Flag Post

Topic: Game Programming / Creating an app for android: Where did i go wrong?

I’ve tried calling the class from my timeframe, and doing this made me notice how the diceroller.as doesn’t seem connected to the project at all!
I’m not quite sure how to do this, import src.diceroller doesn’t seem to work.

Maybe it’s got something to do with Flex?

EDIT: I copied the code from diceroller.as and removed the public tags + Class tag and such, posted it on my timeframe script and i’m just getting random script errors now i should be able to resolve. I would like to know what I’ve done wrong, because i prefer having it ordered in different files so I don’t lose anything.

EDIT2: Still having problems, could anyone have a look at my new code?

http://snipsave.com/user/redstuf

I’m getting the following errors:

Scène 1, layer ‘Actions’, frame 1, regel 31 1046: Type was not found or was not a compile-time constant text.
Scène 1, layer ‘Actions’, frame 1, regel 31 1119: Access of possibly undefined property text through a reference with static type Class.
Scène 1, layer ‘Actions’, frame 1, regel 80 1136: Incorrect number of arguments. Expected 1.

I’m really lost.

 
Flag Post

Topic: Game Programming / Creating an app for android: Where did i go wrong?

Oh, I get it, so if you tap an item, it registers as an event.target with the name of the instance you tap.
Probably a stupid question, but how would I implement this in a function?

 
Flag Post

Topic: Game Programming / Creating an app for android: Where did i go wrong?

So is it

event.target = d4

And then what?

 
Flag Post

Topic: Game Programming / Creating an app for android: Where did i go wrong?

TOUCH_BEGIN doesn’t seem to work, and I’m not quite sure what you mean by adding them to the stage.

 
Flag Post

Topic: Game Programming / Creating an app for android: Where did i go wrong?

Here you go:

https://docs.google.com/open?id=0B4IpyZRVr2ojUWFMSXlreDkzQVk

I’ve zipped them for convenience, but i can also upload them separately if you want me to.

Thanks in advance :)

 
Flag Post

Topic: Game Programming / Creating an app for android: Where did i go wrong?

No, none of them work. I’ve added tracers to check if it actually sets the variable to a number, but the whole function doesn’t seem to trigger.

 
Flag Post

Topic: Game Programming / Creating an app for android: Where did i go wrong?

This:
D8.addEventListener(TouchEvent.TOUCH_TAP, d8);
Doesn’t trigger by touching the button

Or this:
D8.addEventListener(TouchEvent.TOUCH_TAP, d8);

Doesn’t trigger this:
function d8(event:TouchEvent):void
{
die = 8;
}

 
Flag Post

Topic: Game Programming / Creating an app for android: Where did i go wrong?

That does clear things up indeed.

It took me a while to figure out, but i now see that i’m calling number X instead of times.
Let’s see if i can fix it.

EDIT: It appears i can’t fix it. Rofl.
EDIT2: I’ve been poking around a bit and it seems that the touchevent somehow
a: Doesn’t trigger
b: Doesn’t trigger the function

 
Flag Post

Topic: Game Programming / Creating an app for android: Where did i go wrong?

Dear Kongregaters,

I’ve been working my way through errors hoping that i would finally be able to use this simple app I made. I finally got stuck and I need your help.

The app is supposed to be a simple diceroller, that takes input from 6 buttons (1 button for each die, (4, 6, 8, 10, 12, 20) and is supposed to multiply that with the number specified in the text field.

Although I don’t get any errors, and it exports to my phone just fine, pressing the roll button does not do anything.

You can find both .as files here:

http://snipsave.com/user/redstuf

I am aware that my coding is not… efficient at all, but i hope someone can help.

P.S. I’m not quite sure if any of the buttons do anything, but I am sure i can press the buttons (By adding an OnPressed)

P.S.S Please don’t skip the real rookie fails, this is my first real code in AS3

 
Flag Post

Topic: Game Programming / Flash games don't work properly

I have an little problem with flash. There are in total 2 problems:
-When i play a flash game (Doesn’t counts for all games) the character i move bugs (Like he walks to the left when i do nothing, and still walking to the left when i press right)
-When i write an Actionscript file, (All properly of course) It doesn’t works with the flash file, and the character i made doesn’t moves…
Thanks in advance