he told me was that FLEX could not consume web services without Flex Data
Services
Uh, no. You can consume webservices in Flex. I'm guessing it must conform to
SOAP, which shouldn't be a problem. .NET, CF, all good.
Is this true, or can FLEX consume a web serivce but with limiations? By
The Array.splice method, in AS1 at least, is very slow. For that
reason, In situations like this where you would make repeated calls
to it to remove one item I prefer to:
- create a new Array
- iterate the original array with a for loop
- push the items I want to keep into the new array
-
] On Behalf
Of Arindam Dhar
Sent: Friday, December 22, 2006 12:10 AM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Remove elements from Array
function removeElements(arr, level) {
for (var i = 0; i {
var tempArr = arr[i];
if(Number(tempArr[1] ) Number(level))
{
arr.splice(i, 1
Try this,
var myArray1:Array = new Array();
myArray1.push( new Array(A:, -1) );
myArray1.push( new Array(B:, -1) );
myArray1.push( new Array(C:, 0) );
myArray1.push( new Array(D:, 0) );
myArray1.push( new Array(E:, -1) );
myArray1.push( new Array(F:, 1) );
myArray1.push( new Array(G:, 0)
: [Flashcoders] Remove elements from Array
function removeElements(arr, level) {
for (var i = 0; iarr.length; i++)
{
var tempArr = arr[i];
if(Number(tempArr[1] ) Number(level))
{
arr.splice(i, 1);
arguments.callee(arr, level);
}
}
}
removeElements(myArray1
I have a Flex question. I have been considering FLEX 2.0, but when I spoke
with the guy at Adobe, the first thing he told me was that FLEX could not
consume web services without Flex Data Services and the price he quoted me for
the Departmental License was (well, lets not say).
Is this true,
What if you create a new array and push the good values ( 0 ) onto it,
then replace the old array with the new, at the end of the loop?
Simple. Efficient? Probably, unless your array gets huge.
-Scott
On 12/21/06, Mike Cobb [EMAIL PROTECTED] wrote:
-
Hi everyone,
I'm having a braindead
you could use a while loop:
var i:Number = 0
while(i myArray1.length) {
if(myArray1[i][1] == 0) {
/* I think this is right: */
myArray1.splice(i, 1);
} else {
i++;
}
}
Splicing will cause the next item to be at index i, so you want to
recheck that index the next time through the
That's probably more efficient than my method. Granted, I may be
wrong about how Flash stores arrays internally, but in general
removing a single element from an array requires everything after that
element to be shifted left. So the closer to the beginning of the
array the more expensive the
-
oh brilliant - just what I needed.
Thanks Andy!
Andy Herrman wrote:
you could use a while loop:
var i:Number = 0
while(i myArray1.length) {
if(myArray1[i][1] == 0) {
/* I think this is right: */
myArray1.splice(i, 1);
} else {
i++;
}
}
Splicing will cause the next item to be
//Create array with 5 elements
var myArray1:Array = new Array();
myArray1.push( new Array(A:, -1) );
myArray1.push( new Array(B:, -1) );
myArray1.push( new Array(C:, 0) );
myArray1.push( new Array(D:, 0) );
myArray1.push( new Array(E:, -1) );
myArray1.push( new Array(F:, 1) );
myArray1.push(
-
Thanks Michael - that's an elegant solution.
Don't worry about the array name though - just a simplified example for
the sake of the list.
Thanks again all.
T. Michael Keesey wrote:
Quite simple:
for (var key:String in myArray1) {
if (myArray1[key][1] 0) {
Wouldn't doing the splice there change the indexes of everything else
in the array and mess up the loop?
For instance:
[1, 2, A, A, 5, A, 7]
say you're deleting the As.
The first time you do a splice you remove the first one, and get:
[1, 2, A, 5, A, 7]
The index of everything after the
No, because it's a for (x in a) loop, not a for (x; y; z) loop. In AS2
it iterates backwards over the elements. Not sure about AS3, but it
should work there, too. Try it and see!
On 12/21/06, Andy Herrman [EMAIL PROTECTED] wrote:
Wouldn't doing the splice there change the indexes of everything
Even if it iterates backwards, I don't think I'd trust it. I don't
like the idea of relying on an implementation detail of the for-in
loop in order to make my stuff work. In general I see for-in loops
(any language) as loops that use an arbitrary ordering, and as such
you shouldn't rely on any
Well, easy enough, then:
for (var i:Number = array.length - 1; i = 0; --i) {
if (!test(array[i])) {
array.splice(i, 1);
}
}
On 12/21/06, Andy Herrman [EMAIL PROTECTED] wrote:
Even if it iterates backwards, I don't think I'd trust it. I don't
like the idea of relying on an
for (var i:Number = array.length - 1; i = 0; --i) {
if (!test(array[i])) {
array.splice(i, 1);
}
}
This is correct and well tested... Look in any of the AS code
libraries and you'll find many variations on this theme.
Jim Kremens
On 12/21/06, T. Michael Keesey [EMAIL PROTECTED]
Well now I just feel dumb. That's much better than my while loop, and
simple enough I should have thought of it (I've even done something
like that before). Doh!
-Andy
On 12/21/06, Jim Kremens [EMAIL PROTECTED] wrote:
for (var i:Number = array.length - 1; i = 0; --i) {
if
18 matches
Mail list logo