Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
Flash arrays: funkcija za index nekog elementa?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Flash
View previous topic :: View next topic  
Author Message
nemogirl



Joined: 27 Oct 2004
Posts: 386
Location: istra

PostPosted: 30.08.2006 09:51    Post subject: Flash arrays: funkcija za index nekog elementa? Add user to your forum ignore list Reply with quote

kao sto sam naslov kaze: zanima me da li postoji funkcija koja vraca index tj. poziciju odredjenog elementa u nizu?
ja sam to rijesila svojom funkcijom, ali me zanima da li postoji vec ugradjena funkcija za to? nisam nasla na googlu, ali mi je presumnjivo da to ne postoji... Think

moja funkcija:
Code:
function Pozicija(elementa){
   for (indeks=0; indeks<Niz.length; indeks++) {
      if (Niz[indeks]==elementa){
         return indeks;
         }
      }
   
   }
Back to top
View user's profile Send private message
dblchckd



Joined: 02 Apr 2006
Posts: 106

PostPosted: 02.09.2006 15:16    Post subject: Add user to your forum ignore list Reply with quote

Mislim da Array klasa nema takvu methodu, kao sto String ima indexof().

A ovu tvoju custom funkciju koja vraca index bi mogla napisati tako da ime niza dodajes kao parametar umjesto da ga hardcodiras, pa bi je mogla primjenjivati u svakoj prilici...
Back to top
View user's profile Send private message
zytzagoo
mi3.crew


Joined: 25 Aug 2003
Posts: 1842
Location: Zagreb, Hrvatska

PostPosted: 02.09.2006 18:16    Post subject: Add user to your forum ignore list Reply with quote

mozes napisati svoju, i to tako da prosiris samu Array klasu...

Code:
Array.prototype.getInd = function(value) {
        for (var i in this) {
                if (this[i] == value) {
                        return i;
                }
        }
};


A zahvaljujuci tome, onda mozes koristiti nesto poput:
Code:
Niz.getInd(elementa);


nisam bas testirao, ali teoretski to bi trebalo bit to : )

edit: zaboravio link sa kojeg je to izvuceno: http://www.19.5degs.com/element/881.php

_________________
[+]I[+]am[+]my[+]own[+]religion[+]
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Flash All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group