Recent posts by pizzagurkan on Kongregate

Flag Post

Topic: Game Programming / Keyboard problem :O [AS3]

Hello! I want to do so if you press the down arrow on the keyboard, you’ll trace “Lol!” once. The code you can see below works perfect for this.
So what is the problem? Well… if I’m holding the down-arrowkey for a few seconds, flash will trace “Lol!” multiple times! How do I fix this?

Thanks for reading!

Code:

stage.addEventListener(KeyboardEvent.KEY_DOWN, toTrace);
function toTrace(e:KeyboardEvent):void{
if (e.keyCode == Keyboard.DOWN){
trace(“Lol!”);
}
}

 
Flag Post

Topic: Game Programming / Edit a variable with a textbox [One last question!]

Originally posted by MoonlaughMaster:
Originally posted by pizzagurkan:

Still the same problem :(
The output still says “4” insted of “4.3”, (I wrote 4.3 in the inputbox) :(

Did you make ‘thevariable’ a number?

When I replaced “parseInt” with “parseNumber”, “parseNumber” didn’t turn blue in the code :(

 
Flag Post

Topic: Game Programming / Edit a variable with a textbox [One last question!]

Still the same problem :(
The output still says “4” insted of “4.3”, (I wrote 4.3 in the inputbox) :(

 
Flag Post

Topic: Game Programming / Edit a variable with a textbox [One last question!]

It didn’t work :( Let’s say I have 1 inputbox and this code inside the frame:


theinputbox.restrict="0-9\\-.";
var thevariable:int;

stage.addEventListener(Event.ENTER_FRAME,write);

function write(e:Event):void{
	thevariable = parseInt(theinputbox.text);
	trace(thevariable);
}

Let’s test this out. Now when I insert, for an example, the number “5” in the textbox, I will in the output get the letter “5”.
Let’s try “5.5”. The output still says “5”. Lets try “0.7”, but then it will only say “0”… Why? :(
Please help :D

 
Flag Post

Topic: Game Programming / Edit a variable with a textbox [One last question!]

Hello!
myTextfield.restrict=“0-9\\-”;
^ That worked! Thanks!

So now I can make negative variables… But how about decimals?
So I tried:
myTextfield.restrict=“0-9\\-\\.”;
But it didn’t work :(
What to do?

 
Flag Post

Topic: Game Programming / Edit a variable with a textbox [One last question!]

Originally posted by BobTheCoolGuy:
Originally posted by pizzagurkan:
Originally posted by BobTheCoolGuy:

var myNum:int = parseInt(mytextbox.text);

If you want it to only let them type in numbers, just do:
myTextBox.restrict="0-9";

Thank you very much!
One last thing, how could I make so you could write “-” too?
So you could write negative numbers :)
I tried:
myTextBox.restrict=“0-9”+"-";
But it did not work :(

You probably have to escape it. try something like:

myTextfield.restrict="0-9\\-"
A little strange syntax because you need two \\, but that’s just because they evaluate to a \ which then escapes the -

THANKS!

 
Flag Post

Topic: Game Programming / Edit a variable with a textbox [One last question!]

Originally posted by BobTheCoolGuy:

var myNum:int = parseInt(mytextbox.text);

If you want it to only let them type in numbers, just do:
myTextBox.restrict="0-9";

Thank you very much!
One last thing, how could I make so you could write “-” too?
So you could write negative numbers :)
I tried:
myTextBox.restrict=“0-9”+"-";
But it did not work :(

 
Flag Post

Topic: Game Programming / Edit a variable with a textbox [One last question!]

Hello!
I have a variable and a textbox.

I want to make so if I write “5” in the textbox, the variable will be “5”.
And if im writing “7”, the variable will be “7”!
How can I make this?

P.S. Is there some way you could make so the textbox only allows numbers?

 
Flag Post

Topic: Game Programming / If statement in a MC need to know somethin about a var in the main timeline

Originally posted by panerarocks:

You may try putting dispatchEvent in the drive function, then in the MC, if you listen for it, it should pick it up. That would be the easiest thing to do I think.

More exactly how do I do that?

 
Flag Post

Topic: Game Programming / If statement in a MC need to know somethin about a var in the main timeline

Okay, Lets just change “va” to “theSuperUberCoolVariableName”.
Okay. But if I am on the main timeline and want to reach the code inside the MC called car.
Like…
I got this in the main timeline:

var theSuperUberCoolVariableName:Number = 1;

theCarrButton.addEventListener(MouseEvent.CLICK, drive);

function drive(e:MouseEvent):void{
stage.addEventListener(Event.ENTER_FRAME, sayjah);
}

And this in the MC:


function sayjah(e:Event):void{
if (theSuperUberCoolVariableName == 1){
trace("Jah");
}
}

i tried to put car.stage.addEventListener(Event.ENTER_FRAME, sayjah); but it didnt work :(

 
Flag Post

Topic: Game Programming / If statement in a MC need to know somethin about a var in the main timeline

I tried _root before. Didnt work :(

 
Flag Post

Topic: Game Programming / If statement in a MC need to know somethin about a var in the main timeline

Hello.

In the main timeline i got this:


var va:Number = 1;

I have this code in a MC called “car”:


stage.addEventListener(Event.ENTER_FRAME, sayjah);
function sayjah(e:Event):void{
if (va == 1){
trace("Jah");
}
}

Does´nt work. So how do i say like “if (va in the main timeline == 1){”

Thanks for answering!

 
Flag Post

Topic: Game Programming / How can i make many diffrent variables

Okay… so in english it means?.. that I need to put this in the code:
for(var i:int=0;i<=candy.length;i++){
????

 
Flag Post

Topic: Game Programming / How can i make many diffrent variables

Mr. Error Box says:
for(i=candy.length-1;i>-1;i—){ is an syntax error.

 
Flag Post

Topic: Game Programming / How can i make many diffrent variables

Mr.Error Box says:
1176: Comparison between a value with static type Number and a possibly unrelated type Array.
if(smilieguy.x==candy){

 
Flag Post

Topic: Game Programming / How can i make many diffrent variables

Okay. Why didnt this work:

var candy:Array = new Array();

stage.addEventListener(MouseEvent.CLICK,gamie);

function gamie(e:MouseEvent):void{
effekter.push(mouseX);
if(smilieguy.x==candy){
trace(“Yummy!”);
}
}

 
Flag Post

Topic: Game Programming / How can i make many diffrent variables

Okay… so then i can just call all the numbers with “yourArray”?)
Like for exampel:
trace(yourArray);

 
Flag Post

Topic: Game Programming / How can i make many diffrent variables

How do i do so when you click on the stage you´ll create a variable with that x coordinate you had. And you can click and create many of them… not just 1.

So the question is: Can a variable´s have many diffrent numbers in it, or do I need to do so it creates 1 new variable each time. And if so… how do i use them in a code. I can´t list all?

Can i use an array?

Thanks for answering.

 
Flag Post

Topic: Game Programming / How do i interact with my children? (AS3)

Originally posted by Draco18s:

I’

To the OP’s question, that code appears to be correct, but will only run when you click ON the Kiddo movieclip.

Well… its not that. Im getting this in the error box:
1046: Type was not found or was not a compile-time constant: MouseEvent.
and the error box says it something wrong with the .as thing.

 
Flag Post

Topic: Game Programming / How do i interact with my children? (AS3)

package{

     import flash.display.MovieClip;
     import flash.events.MouseEvent; 

     public class Kiddo extends MovieClip{    
          public function Kiddo(){     
               addEventListener(MouseEvent.CLICK, Clicky);
          }

          private function Clicky(e:MouseEvent):void{
               rotation += 180;
          }
     }
}

Wuts wrong?

 
Flag Post

Topic: Game Programming / How do i interact with my children? (AS3)

Well… they also say its something wrong with this bud:
private function onClick(e:MouseEvent):void{

 
Flag Post

Topic: Game Programming / How do i interact with my children? (AS3)

Still gettin this:
1046: Type was not found or was not a compile-time constant: MouseEvent.

 
Flag Post

Topic: Game Programming / How do i interact with my children? (AS3)

Okay, i have a fla and there i have my wonderfull Child named Kiddo.
Well… i made an Actionscript document also.
an .as file. I named it Kiddo.as and putted this code in:


package{

import flash.display.MovieClip; import flash.display.MouseEvent; public class Kiddo extends MovieClip{ public function Kiddo(){ addEventListener(MouseEvent.CLICK, onClick); } private function onClick(e:MouseEvent):void{ rotation += 180; } }

}

Well. I get this in the error box:
Source: private function onClick(e:MouseEvent):void{
Description: 1046: Type was not found or was not a compile-time constant: MouseEvent.

Wut?!

 
Flag Post

Topic: Game Programming / How do i interact with my children? (AS3)

I got this:

5008: The name of definition ‘reallylightnote’ does not reflect the location of this file. Please change the definition’s name inside this file, or rename the file. C:\Users\Carr77\Desktop\A game\Reallylightnote.as

?????

DO i need to change the name of anything?

 
Flag Post

Topic: Game Programming / How do i interact with my children? (AS3)

When you say “After the word package, enter the directory where the file will be saved in relation to the .fla” fo you mean like:
“Desktop/Flash files/Game.fla”?

Searched around some tutorials but it didnt look that way. Some didnt have anything after “package{”.
Well… please help. Because i know we are soo close to solve this thing!