Return Vector Array


/ Published in: ActionScript 3
Save to your folder(s)

1067: Implicit coercion of a value of type __AS3__.vec:Vector. to an unrelated type __AS3__.vec:Vector.


Copy this code and paste it in your HTML
  1. public function getMainItems():Vector.<VOItem>
  2. {
  3. //Length of Main items
  4. MainItemLn = xml.item.length();
  5.  
  6. //Vector class of MainItems
  7. var MainVO:Vector = new Vector.<VOItem>(MainItemLn,true);
  8.  
  9. for(var i:int = 0; i < MainItemLn; ++i)
  10. {
  11. MainVO[i] = new VOItem();
  12. MainVO[i].id = i;
  13. MainVO[i].title = xml.item[i].@title;
  14. MainVO[i].img = xml.item[i].@img;
  15. }
  16.  
  17. return MainVO
  18. }
  19.  
  20. trace(getMainItems()[0].title);
  21. //or
  22. trace(getMainItems()[1].title);
  23. //and so on..
  24. .
  25. .
  26. .

URL: http://blog.alptugan.com/?p=380

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.