Adobe Dreamweaver Forums



Last 10 THreads :         Re: Paint, erase, burn and dodge won't work for me in CS4 (Last Post : John Joslin - Replies : 0 - Views : 1 )           »          Re: Photoshop's User Interface brightness (Last Post : Lukas_Dubeda@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: Paint, erase, burn and dodge won't work for me in CS4 (Last Post : harold_berm@adobeforums.com - Replies : 0 - Views : 1 )           »          New nVidia drivers 08JAN09 (Last Post : chris_farrell@adobeforums.com - Replies : 2 - Views : 3 )           »          Confused - Color control with multiple utilities available (Last Post : chris_farrell@adobeforums.com - Replies : 3 - Views : 4 )           »          Re: Paint, erase, burn and dodge won't work for me in CS4 (Last Post : dave_milbut@adobeforums.com - Replies : 0 - Views : 1 )           »          CS4 SaveForWeb Still Stripping EXIF???!!! (Last Post : Paul_R@adobeforums.com - Replies : 5 - Views : 6 )           »          Re: Lagging in CS3 Extended due to Antivirus permissions (Last Post : Don_Gough@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: Paint, erase, burn and dodge won't work for me in CS4 (Last Post : Stephen_Gingold@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: Your techiques for removing specular from photos (Last Post : Mark_Reynolds@adobeforums.com - Replies : 0 - Views : 1 )           »         


User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-03-2008, 04:39 AM
jcahill23
 
Posts: n/a
Diggs:
Default Help with this "for" loop...!

Hi. I have saved an ArrayCollection to the desktop. When I read it back into
the application I get the problem that the ArrayCollection is now a collection
of Objects, not a collection of type "Player" which is the class representing
each of the elements in the ArrayCollection. Each Player class has three string
properties associated with it.

I created a function to "type" the elements of the ArrayCollection. It takes
the ArrayCollection that has been saved on the desktop as the first argument
and the "Player" class as the second argument and should return an
ArrayCollection that is typed.

Trying to figure out why it keeps throwing up an error...and whether i need a
second for loop inside the first that passes all the variables from the item
objects to the temp object.

Thanks!

private function typeCollection (collection:Object,
clazz:Class):ArrayCollection

{
var arr:ArrayCollection = new ArrayCollection();
for each (var item:Object in collection) {

var temp:Object = new clazz()
temp = item;
arr.addItem(temp);
}
return arr; //return the array collection
}




Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-03-2008, 04:39 AM
Greg Lafrance
 
Posts: n/a
Diggs:
Default Re: Help with this "for" loop...!

What is the error and what is clazz in:
var temp:Object = new clazz()

Reply With Quote
  #3 (permalink)  
Old 11-03-2008, 04:39 AM
jcahill23
 
Posts: n/a
Diggs:
Default Re: Help with this "for" loop...!

Hi.

The error I get is below....

ArgumentError: Error #1063: Argument count mismatch on Player(). Expected 3,
got 0. at main/typeCollection()[C:\Documents and Settings\User\My
Documents\Flex Builder 3\main\src\main.mxml:108]

Line 108 is the line var temp:Object = new clazz();

When you ask what is clazz in...clazz represents the second argument of the
typeCollection function and the argument that is passed in is the class Player
which is a class in an external actionscript file.

Actually just got it to work. The problem was....i created the Player class'
constructor function to accept three arguments (id, firstname, surname)....and
so new clazz() should have had 3 arguments....i just changed the code below and
it seems to work..

If there is a better way happy to hear!

Thanks for responding.


private function typeCollection (collection:Object,
claz:Class):ArrayCollection

{
var arr:ArrayCollection = new ArrayCollection();

var a:String;
var b:String;
var c:String;

for each (var item:Object in collection) {

var temp:Object = new claz(a,b,c)
temp = item;
arr.addItem(temp);
}


Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 11:16 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk