Welcome, Guest. Please login or register.
Did you miss your activation email?
05/21/12, 04:42
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  V2 Components (Flash MX 2004 - Flash 8) (Moderators: vesa kortelainen, Ronald Wernecke, Jorge Solis, ..:: Mazhar Hasan ::.., papachan)
| | |-+  what I'm I doing wrong?
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 Print
Author Topic: what I'm I doing wrong?  (Read 9250 times)
Pluda
Senior Programmer
****
Posts: 270


View Profile
« on: 01/08/07, 05:48 »

Hello, I need some help here, since I'm working on this since lat thurday and I can't find a solution.

I've 2 swf's, "main.swf" wich as one datagrid and "lodaded.swf" wich has  4 textfields in stage and 2 buttons one called "continue" and one called "finish"

What I want

on continue press I want to add to the datagrid the text in my loaded.swf textfiels and if I press continue again I want to add, not to replace to the datagrid

btn_enc.onRelease = function() {
_global.n++;
ref = "ref"+_global.n;
//
ref = new Array({Quantity:_quant_.text, REF:load_detalhes_produto.ref, Taxes:_total_iva.text, Total:valor_total.text});
_root.grid.addItem(ref);
}

using this simple code I can't make this work, but I'm not seeing what else can I use...

Any sugestion?

Thanks

Pluda
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #1 on: 01/08/07, 06:32 »

you are in the button, so you have to address your textfields with _parent._quant_.text etc.
Logged

happy flashing
Cool
Ronald
Pluda
Senior Programmer
****
Posts: 270


View Profile
« Reply #2 on: 01/08/07, 06:55 »

Hello, thanks for reply

no, I'm not in button, the textfields are in the same swf as the button, so using just _quant_.text works good, I trace the text without any problem.

I think the problem is the way I'm making the datagrid populated, but I can't find where the error is

Thanks
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #3 on: 01/08/07, 16:07 »

syntax doesnt realy look bad - try to trace all the variables for ilegal characters - and try the same syntax with the values you receive.
It might be the values

Logged

happy flashing
Cool
Ronald
Andresss
Systems Administrator
*****
Posts: 738


check me out at www.asb-labs.com/blog


View Profile WWW Email
« Reply #4 on: 01/10/07, 00:31 »

hi Pluda! just a doubt why you wrote?:

ref = "ref"+_global.n;

and once you set the var "n" to _global, it is not necessary to write _global once again, just by writing "n"

cheers!!
Logged

halemos de flash en español!....wondering about crazy flash experiments?
Pluda
Senior Programmer
****
Posts: 270


View Profile
« Reply #5 on: 01/11/07, 11:36 »

Hello, sorry for latness response, I had to format my hard drive.

I found a sollution, I had to use object instead of array like this

btn_enc.onRelease = function() {
var refer:Object = {Quantity:""+_quant_.text+"", REF:""+load_detalhes_produto.referencia+"", Taxes:""+_total_iva.text+"", Total:""+valor_total.text+""};
_root.grid.addItem(refer);
};

but now I've one more problem, I hope you can help me here too

Is it possible to add onother raw to the datagrid to show the total of items and how much user will have to pay?

I mean, each row as price, taxes and price+taxes

I want to have the total at the end, how do I do that?

Thanks a lot for help

Pluda
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #6 on: 01/11/07, 15:15 »

you mean a new collumn - sure you can - but then you have to add this collumn to your records as well Wink
Logged

happy flashing
Cool
Ronald
Andresss
Systems Administrator
*****
Posts: 738


check me out at www.asb-labs.com/blog


View Profile WWW Email
« Reply #7 on: 01/11/07, 15:26 »

hey hi Pluda! good you did it! for your new task you can use the dataProvider class since you have to count quantities and stuff right?, ok supposing your user has to click some chec out btn the btn will need to have this code:

on(click){
//here you sould set some vars representing columns
var col1:Number
var col2:Number
//etc
for(i =0;i<_root.grid.dataProvider.length;i++){
//here you should sum your data
col1+=_root.grid.dataProvider.column_name
col2+=_root.grid.dataProvider.column_name
}
//and insert last row
_root.grid.addItem({row1:col1,row2:col2})
}

//now if this doesn´t work you should use the dataset component and let the component administer your datagrid, and becomes easier, in case you wonder how to insert data into it, it is exactly as inserting to the datagrid.
((also check the Componet Inspector panel too))
Logged

halemos de flash en español!....wondering about crazy flash experiments?
Pluda
Senior Programmer
****
Posts: 270


View Profile
« Reply #8 on: 01/12/07, 10:36 »

Hello again,

it doesn't work good :-(

the code you give me works to add one final row in datagrid, but the sum doesn't work
instead of having a sum of all the row values I get per exemple     12,4534,67,21,87   instead of the sum of 12,45 + 34,67 + 21,87

so far this is the code

var col1:Number;
var col2:Number;
for (i=0; i<_root.grid.dataProvider.length; i++) {
//here you should sum your data
getURL("javascript:alert('"+i+"')");
getURL("javascript:alert('"+_root.grid.dataProvider.Taxes+"')");
col1 += _root.grid.dataProvider.Taxes;
col2 += _root.grid.dataProvider.Total;
}
//and insert last row
_root.grid.addItem({Taxes:col1, Total:col2});


I really don't want to use more components in this work, there must be some kind of loop we must use to make this work.

Thanks!
Logged
Pluda
Senior Programmer
****
Posts: 270


View Profile
« Reply #9 on: 01/12/07, 10:47 »

instead of having a sum of all the row values I get per exemple     12,4534,67,21,87   instead of the sum of 12,45 + 34,67 + 21,87       =     68,99
Logged
Andresss
Systems Administrator
*****
Posts: 738


check me out at www.asb-labs.com/blog


View Profile WWW Email
« Reply #10 on: 01/12/07, 14:18 »

maybe it is being taken as Strings so in order to avoid that use this snippet:

col1 += parseFloat(_root.grid.dataProvider.Taxes);
hope it helps

cheers!!!
Logged

halemos de flash en español!....wondering about crazy flash experiments?
Pluda
Senior Programmer
****
Posts: 270


View Profile
« Reply #11 on: 01/12/07, 14:45 »

Allright, it surely did help a lot!

howeaver I did had  to change this

col1:Number   to col1 = 0

to make it work, but it is now making all the maths function.

Thanks a lot, I was being desesperated :-)

Pluda
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #12 on: 01/14/07, 06:07 »

The definition col1:Number only means, that you have a variable named col1 which can contain Numbers. It is not initialized then - it still contains undefined.
If you want to define it initialized, you ca write: col1:Number=0;
Logged

happy flashing
Cool
Ronald
Pluda
Senior Programmer
****
Posts: 270


View Profile
« Reply #13 on: 03/22/07, 10:02 »

Hello again, need some more help with this issue.

I need to add a function to be able to remove one row on my datagrid, and I can do that, but I also need to recalculate my total, who can I do that?

Many thanks for help,

Pluda
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #14 on: 03/22/07, 15:18 »

After the datagrid can be accessed like an assiciative array, you can walk it through.
Or, which is faster: before you remove the row, reduce the sum field by the value of the row you are removing (in the function where you remove) Wink
Logged

happy flashing
Cool
Ronald
Pages: [1] 2 Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!