|
-
Master of disaster
re
If i type 19.10.03 it produce 31.10.13312 in first loop.
What could be wrong? Oh I’m reminding you for zero afore month if it is less than 10 i.e. 04 or 05;
Thanks
-
Master of disaster
re
I found what is wrong,
the code:
datAry = otplata.split('.');
yr = datAry[2];
if (yr < 100) yr += 20;
read only first member of year actually it reads only null/zero if i type .04 for year.
how it could be done to read both numbers?
-
Master of disaster
re
Sorry for they who I’m boring, but this is the right way for learning i guess and hope.
I removed lineif (yr < 100) yr += 2000;
and now it prodused me satisfied format only less for one hundred years, i.e. 1905 instead 2005.
Last edited by jugomkd75; 06-12-2004 at 08:17 AM.
-
Master of disaster
re
Nobody that could tell me how to put null before months if are less than 10,
if (mn < 10){
mn = "0" + mn;
}
where need to be written and do it's the right way or there is better one?
and explain why years show the right function but less for 100 years than expected number?
In meantime it appear one more anomaly; if i type for months 01, 02, 03, etc. in first loop it show me NaNNaNNaN, after go well, what i need to improve to resolve this?
Thanks in advance,
JUGO
Last edited by jugomkd75; 06-12-2004 at 07:27 AM.
-
Master of disaster
Jbum,
I almost finished my all issues (for year i prolong to input whole year i.e. 2005 instead 05) but i just cannot figure out for months. I spent a lot of time in testing but nothing. Issue is follow:
if i type 10,11,12 for months it works great, but if i type 01,02,03,04 .... 09, it works well except in first loop, it appears NaN, and after continue to collate next as well. I cannot understand way.
Please help,
It could be last one,
JUGO
-
Senior Member
I would suggest removing the leading zero and then converting it to a number using Number(str).
code:
// get month from user input
mn = datAry[1];
// removing leading zero, if any
if (mn.charAt(0) == '0')
{
mn = mn.substr(1);
}
// convert to number and subtract 1
mn = Number(mn) - 1;
// now it should be equal to 0 - 11
-
Master of disaster
Huston, Project Accomplished!
Huston we got a problem!!!
It is only past, now is valid next one:
Huston, project accomplished!!!
Owing and Thanks To Jbum and his Unselfish cooperation the project is finally finished up.
I just have some Scruples to set up and tomorrow I promise that whole project will be uploaded on this forum so it will be free and could be used by anyone who has need for it. I will try to translate in English as well so it will be useful for wide range of users and members of this forum.
Thanks again Jbum,
JUGO
-
Master of disaster
Chieftain Appreciative Jugo
Huston i guess we have problem again! Sorry!
I've been not account on this problem but what is here, here is 
When i embed all needed values for calculation i press the button "Calculate" or Enter and timeline go to frame "done" and everything is well. But what when i need to compute another one loan?
I putted new button that would be back me on the "start" frame (1st frame). It did its job but the table (many text fields) that have been drawn staying on the scene and overlap everything on frame start.
The code that I’ve joined to this button:
code:
on (release){
gotoAndPlay("start");
iznos = "";
stapka="";
metod = "";
pustanje = "";
rati = "";
otplata = "";
selection.setFocus("iznos");
for (i=0;i<rati;i++){
for(j=0;j<6;j++){
__name.removeTextField();
}
}
updateAfterEvent();
}
I want to point out how I drawing this tables so maybe the names for removing textFields not correspond to the __name:
code:
//this function create empty textFields;
function CreateTable(thename, x, y, width, height, no_of_rows, no_of_columns, data, parent){
c=0;
for(i=0;i<no_of_rows;i++){
for(j=0;j<no_of_columns;j++){
// Create the new name for the text field
__name=thename+"_"+i+"_"+j;
// Create the text field
parent. createTextField(__name,c++,j*width+x,i*height+y,wi dth,height);
// Set the data and other settings
temp=parent[__name];
temp.text=data[i][j];
temp.background=false;
temp.border=false;
myformat = new TextFormat();
myformat.color = 0x000000;
myformat.font = "Arial";
myformat.size = 9;
myformat.align = "right";
temp.setTextFormat(myformat);
}
}
}
and here I call function createTable() to draw needed numbers of rows and values inside;
code:
myData = [];
for (i=0; i < rati+1; i++){
komforna(k);
m=i+1;
b = a-k;
//ova e za razdeluvanje na broevite;
k= RoundToQuarter(k);
b= RoundToQuarter(b);
a= RoundToQuarter(a);
z= RoundToQuarter(z);
var dat = new Date(yr,mn,getMonthDays(yr,mn));
var datString = dat.getDate() + '.' + (dat.getMonth()+1) + '.' + dat.getFullYear();
if (++mn >= 12) {
mn = 0;
yr++;
}
myData[i] = [m, datString, EncodeCurrency(z), EncodeCurrency(b), EncodeCurrency(k), EncodeCurrency(a)];
z=z-b;
}
CreateTable("MyTable", 50, 120, 100, 14, rati, 6, myData, this);
I tried everything that I knew, but still nothing, maybe instead removeTextField() I could use different technique as well, please let me know.
Appreciative Jugo
Last edited by jugomkd75; 06-13-2004 at 09:58 AM.
-
Master of disaster
last chance
Seems to me that noone don't want to help 
I guess my problem is with depth connected.
When i'm drawing textFields it goes on same level with rest on stage.
But what code i need to preserve it, or to swapDepths() after drawing?
Please dudes, help me,
Jugo
-
Yes. Here I am again. Sorry for me taking so long.
It seems like you don't remove the textFields correctly! You must be careful. I will point out your mistakes with this code:
code:
function DestroyTable(thename, parent){
not_finished_whole=true;
i=0;
// The following while loops will loop through
// all the textfields
while(not_finished_wholw){
j=0;
not_finished_row=true;
while(not_finished_row){
// You have forgotten to do this (note that you
// have to reference to the parent movie clip -
// this is where the table is located):
__name=parent[thename+"_"+i+"_"+j];
// We have reached the end of the row
// Check if we are not finished with
// the whole table
if(__name == undefined){
if(j==0){
not_finished_whole=false;
not_finished_row=false;
} else {
not_finished_row=false;
}
}
// Remove the textField
__name.removeTextField();
j++;
}
i++;
}
}
If you have created the table with such a call:
code:
CreateTable("MyTable", 50, 120, 100, 14, rati, 6, myData, this);
you must delete it with this call:
code:
DestroyTable("MyTable", this);
If it doesn't work tell me.
best regards
Last edited by MatejKo; 06-19-2004 at 03:23 PM.
-
Master of disaster
Thanks, thanks ......
Thanks Matejko Friend,
I'm very happy because we cooperate as before, when Yugoslavia was Whole I'm just little kidding (but every jokes are Half Truths).
Thanks a lot for your solution and extra comments besides the code that help me too much, as well.
I have tried this above and it work perfectly, Although i have resolved this before with Jbum. I done this like next:
First i create an Empty movie clip (container) inside main movie so after when i call function createTable i use:
code:
//instead this i use "container" (name of movieClip);
CreateTable("MyTable", 50, 120, 100, 14, rati, 6, myData, container);
And when i need to remove table i just simple use:
code:
container.removeMovieClip();
It's an easier way but your is the one, with whole respect toward jbum's solution, off course.
Anyhow i want to point out that you have original solutions, and i'm so glad because of that.
See ya till next time,
Best wishes and thanks a lot,
Jugo
Last edited by jugomkd75; 06-19-2004 at 07:28 PM.
-
Hehe, you are right, there is some truth in that joke I do agree with you, and I really enjoy helping you (or anybody), because I'm glad to see that my "inventions" are being appreciated. Here (where I live), nobody actually appreciates what I'm doing, here live only a bunch of idiots - even my parents are unaware what I have thought myself... Ok... a little self-pitying....
Anyhow, the DestroyTable function preserves the movie clip where the table is placed (so, its a general solution). Of course, its very simple to create a movie clip and then just remove it - if I'm honest, I would do it the way jbum said it's much more efficient , but you asked for a general solution, so I gave you one - in case you would want to preserve the movie clip.
Yes, see ya next time
-
Originally posted by jbum
// x is the number you wish to add trailing zeros for
var ix = Math.floor(x);
var fx = x - ix;
fx = String(fx*100+100).substr(1,2);
x = ix + '.' + fx;
trace(x);
That code right there ended my long, LONG search to figure out how to add the right amount of trailing zeros.
jbum, thanks a million!! It's 3:45AM now, so I best be off to bed. I can't stand sleeping when there is unfinished code... I shall rest easy
-
a currency script which returns a currency format like € 1.000,99 or $ 1,000.99
make sure you supply the function with a valid Numer .
Code:
function get_currency(price:Number):String {
//currency symbol -> e.g. €, $, ¥, £
var cur_symbol = "€ ";
//seperation symbol dividin' the currency in quarters -> EU: € 1.999.999,99 / US: $1,999,999.99
var sep_symbol = ".";
//split symbol for divinin' the decimal figure -> 10,00 / 10.00
var deci_symbol = ",";
price = price*100;
price = Math.floor(Math.round(price));
var price_string:String = String(price);
var euros:String = "";
var cents:String = price_string.substring(price_string.length-2, price_string.length);
price_string = price_string.substring(0, price_string.length-2);
while (price_string.length>3) {
euros = sep_symbol+price_string.substring(price_string.length-3, price_string.length)+euros;
price_string = price_string.substring(0, price_string.length-3);
}
euros = price_string.substring(0)+euros;
return (cur_symbol+euros+deci_symbol+cents);
}
//here are some examples
var marshmallows = 32.53252;
var lollipop = 53.3;
var mountenbike = 199.99;
var jaguar = 123456789;
trace(get_currency(marshmallows));
trace(get_currency(lollipop));
trace(get_currency(mountenbike));
trace(get_currency(jaguar));
please enjoy
-
[as]
// make a random number & show it
x = Math.random()*100+Math.random();
trace(x);
[/QUOTE]
i don't want any integer value, how to do it??
-
http://www.in3d.eu
Hi, welcome to FK forum!
Try this AS:
PHP Code:
// make a random number & show it
x = Math.random()*100 + getRandom()
trace(x);
// Custom function: returns a number in the range 0-1 ( 0 < a <1 )
function getRandom() {
var a =Math.random() // 0 <= a <1
while (a == 0) { // Running only while a==0
a = Math.random()
}
return a
}
Best!
Kostas
-
 Originally Posted by Kostas Zotos
Hi, welcome to FK forum!
Try this AS:
PHP Code:
// make a random number & show it
x = Math.random()*100 + getRandom()
trace(x);
// Custom function: returns a number in the range 0-1 ( 0 < a <1 )
function getRandom() {
var a =Math.random() // 0 <= a <1
while (a == 0) { // Running only while a==0
a = Math.random()
}
return a
}
Best!
Kostas
thanks for the replay kostas, but i'm sorry i need without decimal point
-
http://www.in3d.eu
In general: Integers are without point. Float, doubles etc are with points..
You need to round the number ? or need the string equivalent without the decimal point (or something else) ?
PHP Code:
x = Math.random()*100 +Math.random()
//Assume x= 41.7419562333263
x=NoPoint(x) // x= 417419562333263
//x=Math.round(x) // x= 42
//x=Math.floor(x) // x= 41
trace(x)
function NoPoint(Arg:Number):Number{
var Parts=Arg.toString().split(".")
return parseInt(Parts[0] + Parts[1])
}
Kostas
Last edited by Kostas Zotos; 05-21-2008 at 01:50 PM.
-
thanks kostas, but if i need like this
between 0,1,2,4,5,6. this six number is enough for me, and when i click on it (any button/MC) it should change randomly within this number.
-
http://www.in3d.eu
Hi
May use this expression:
var x = Math.round(6*Math.random()); // Returns an integer between 0-6 (eg. 0,1,2,3,..6)
trace(x);
Use this AS (Assume "myButton" is the instance name of your button):
(A button with the previous name is required on stage):
PHP Code:
var x:Number
getRandom() // Just call the function for first time
// Call the function to get a new random value for "x"
myButton.onRelease = function() {
getRandom() // This is the code line you must insert in the other buttons to get a new random value
}
function getRandom(){
x = Math.round(6*Math.random())
trace(x)
}
Kostas
Last edited by Kostas Zotos; 05-22-2008 at 02:41 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|