The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.36 / 5.00 33,851 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 12,195 ViewsJust tried castin everything to an int and here's what happened in the traces:
actualNumbers[0] = 10.
actualNumbers[1] = 15.
actualNumbers[2] = 10.
actualNumbers[3] = 6.
actualNumbers[4] = 3.
actualNumbers[5] = 11.
actualNumbers[6] = 12.
actualNumbers[7] = 12.
actualNumbers[8] = 16.
actualNumbers[9] = 14.
dynamo = 0.
Calc First Result put 0 into calcStages Array. It now has 0 in it.
dynamo = 0.
Res 2 = 0. And the matching calcstages is 0.
dynamo = 0.
Res 3 = 0. And the matching calcstages is 0.
dynamo = 0.
Res 4 = 0. And the matching calcstages is 0.
dynamo = 0.
Res 5 = 0. And the matching calcstages is 0.
dynamo = 0.
Res 6 = 0. And the matching calcstages is 0.
dynamo = 0.
Res 7 = 0. And the matching calcstages is 0.
dynamo = 0.
Res 8 = 0. And the matching calcstages is 0.
dynamo = 0.
Res 9 = 0. And the matching calcstages is 0.
All calcstages:0,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN
The final total is: 0.
At 11/17/12 01:10 AM, 64base wrote: Use parseInt and parseFloat instead
Tried it and all I got back was a bunch of 1067 errors. Implicit conversion of a value of type Number to unrelated type String.
At 11/16/12 08:17 PM, Mattster wrote: What kind of tests are you running? I gave it a try and it works fine.
My guess is that you don't have a value in one of those arrays (which you didn't show the deceleration of)
actualNumbers[0],symbolsOutput[0],actualNumbers[1]
The actualNumbers array is empty to begin with but gets populated with random numbers between 1 and 20 before these activate. The steps are:
- Generate random math symbols
- Generate random numbers between each symbol
- Calculate whatever is thrown together
At the last step, that's where I'm getting my NaNs.
EDIT: Sorry! Forgot about the code tags.
I'm trying to calculate the answer to a series of randomly generated numbers that have randomly generated math symbols.
Generating random numbers and math symbols is working fine. Trouble is, when I try to calculate them, NaN keeps appearing in my trace statements.
Array:
var calcStages:Array = [];
And the Functions:
//calculates the result of ([prime],[+, -, x, /],[second])
function calculateTwo(prime:Number, mod:String, second:Number):Number
{
var dynamo:Number;
switch (mod)
{
case "+":
dynamo = Number((prime + second));
trace("dynamo of this addition: "+dynamo+".");
break;
case "-":
dynamo = Number((prime - second));
trace("dynamo of this subtraction: "+dynamo+".");
break;
case "x":
dynamo = Number((prime * second));
trace("dynamo of this multiplication: "+dynamo+".");
break;
case "÷":
dynamo = Number((prime / second));
trace("dynamo of this division: "+dynamo+".");
break;
}
trace("dynamo = "+dynamo+".");
return dynamo;
}
That one then gets called in the following:
function calcFirstResult():void
{
if(calcStages.length > 0)
{
calcStages = [];
}
else
{
var Result:Number = 0;
Result = Number(calculateTwo(actualNumbers[0],symbolsOutput[0],actualNumbers[1]));
calcStages.push(Number(Result));
trace("Calc First Result put "+Number(Result)+" into calcStages Array. It now has "+calcStages+" in it.");
}
}
I'm trying to calculate the answer to a series of randomly generated numbers that have randomly generated math symbols.
Generating random numbers and math symbols is working fine. Trouble is, when I try to calculate them, NaN keeps appearing in my trace statements.
Array:
[code]var calcStages:Array = [];[/code]
And the Functions:
[code]//calculates the result of ([prime],[+, -, x, /],[second])
function calculateTwo(prime:Number, mod:String, second:Number):Number
{
var dynamo:Number;
switch (mod)
{
case "+":
dynamo = Number((prime + second));
trace("dynamo of this addition: "+dynamo+".");
break;
case "-":
dynamo = Number((prime - second));
trace("dynamo of this subtraction: "+dynamo+".");
break;
case "x":
dynamo = Number((prime * second));
trace("dynamo of this multiplication: "+dynamo+".");
break;
case "÷":
dynamo = Number((prime / second));
trace("dynamo of this division: "+dynamo+".");
break;
}
trace("dynamo = "+dynamo+".");
return dynamo;
}[/code]
That one then gets called in the following:
[code]
function calcFirstResult():void
{
if(calcStages.length > 0)
{
calcStages = [];
}
else
{
var Result:Number = 0;
Result = Number(calculateTwo(actualNumbers[0],symbolsOutput[0],actual Numbers[1]));
calcStages.push(Number(Result));
trace("Calc First Result put "+Number(Result)+" into calcStages Array. It now has "+calcStages+" in it.");
}
}[/code]
Lot of good ideas here.
As for the dot operator, I get that that's how you use built in methods to the class but I remember one of the tutorials saying you could pass other properties and methods back to the class for any instance. That true?
I don't rely on the timeline unless I need an animation. Most of my programs work within one frame.
Not too familiar with how the addChild thing works. What are the benefits with using a sprite rather than a movieclip?
Thanks for you advice. :)
I've been coding for a while now and I can do a fair handful of stuff. But every bone in my body is screaming "YOU NEED TO MASTER CLASSES". I've gone through a handful of tutorials and I can write some of them out, but what stumps me is knowing how and where to use them.
Most of the tutorials have kind of hinted that the best way to use them is to put all of your code inside them so that you don't have to have any code on your timeline. I did that, can see how it would be really useful and it kind of worked but once I added an extra scene (a main menu) it started having seizures.
What I'm more interested in is the being able to generate something new (lets say a scroll bar) without having to write code out for it for each on I might need.
If anyone's interested, could you give some simple examples for these:
1: Creating a new instance of a custom object (lets say a button)
2: How to modify properties and methods when calling an instance (of a button)
3: How to snap multiple movieclips into a one movieclip (for a project I'm working on)
Thanks in advance
Was wondering if anyone out there is developing projects aimed it getting better rather than releasing the next jaw-dropper.
I'm not an amateur but neither am I a seasoned pro...yet.
My main strength is writing AS3 although in a pinch I can do some relatively decent art. My experience with sound is pretty much limited to toying with existing files.
Would really like to get better at this flash thing. So if anyone needs new blood, sign my arse up!
Big love.
My First Game
This took me three days to do. Not very complicated. I followed a tutorial to do this but the original result was far too kid friendly for my tastes so I just twisted it to my 'tastes'.
You will never be able to program a game without coming across a single error. But if you dive into it, you learn a hell of a lot without even meaning to. Not to mention it's very satisfying when you see the parts of your game working after testing.
Best tip I can think of? DO NOT GO STRAIGHT INTO MAKING A TRIPLE-A GAME.
You will give yourself a heart attack and it will demoralize you to the point where you won't want to look at design again.
Start basic. Then expand.
..And don't give up.
At 8/9/12 08:41 AM, Sandremss128 wrote: If you want to load and save data on the hard disk on a specific place instead of a obscure place on the disk where it will be removed; look up : FileReference.
Excellent! Works just as well as the shared objects.
Thanks.
At 8/9/12 05:08 AM, milchreis wrote: welcome to the forums
look for "shared objects"
Fantastic! Works exactly as I want it to.
Thanks.
Hallo,
So I'm trying to export a bunch of data to 'some' data file. Maybe a .txt file or some kind of cookie. Trouble is, I'm green in this respect.
Can anyone suggest a way to import & export data? It's going to be critical for storing scores in a project I'm working on.
Specifically, it's a mental arithmetic program. Generate a series of numbers with calculus symbols between each one. The idea being that you have to work out a solution without using a calculator. A timer keeps track of how long it takes to complete the random puzzle but I was hoping to store the scores so that the user can see them at some point down the line to hopefully see their time decrease (getting sharper with maths).
Thanks in advance.