need help with search function

  • fifin04
  • Student
  • Student
  • fifin04
  • Posts: 70

Post 3+ Months Ago

Ello everyone, I"m newbie in this forum and I hope I post in the rite forum..I tried to make a search function to get my dt that store in Array and dynamically placing blinkMC to the stage based on the dt get from Array....
the whole my data was load from txtfile..so here my attempt code so far...

Code: [ Select ]

lv = new LoadVars();
myArray = [];
lv.onload = function() {
  myArray[0] = this.A.split("||");
  myArray[1] = this.B.split("||");
  myArray[2] = this.C.split("||");
  myArray[3] = this.D.split("||");
  mysortfunction();
};
lv.load("route.txt");

function mysortfunction() {
  for (var i = 0; i<myArray.length; i++) {
   for (var j = 0; j<myArray[i].length; j++) {
     myArray[i][j] = (myArray[i][j]).split(",");
     trace(myArray[i][j]);
     
   }
  }
}
/*stuck at this portion please help me ...
btn.onPress = function() {
  dot.removeMovieClip();
  myVar = input.text;
  for (var i = 0; i<myArray.length; i++) {
   for (var j = 0; j<myArray[i].length; j++) {
     if ( myVar == myArray[i][j][0]) {
      //trace(myArray[i][j][1]+"_"+myArray[i][j][2])
      showMe(Number(myArray[i][j][1]), Number(myArray[i][j][2]));
      //trace(Number(myArray[i][j][1])+Number(myArray[i][j][2]))
     }else if (myArray[i][j][0].indexOf(myVar) != -1) {
      //output += myArray[i][j][0]+newline;
      trace("Not Found !! At least u know the keywords")
      
     }
   }
  }
  
};


function showMe(x, y) {
  this.attachMovie("dot", "dot", 1);
  dot._x = x;
  dot._y = y;
}
*/
  1. lv = new LoadVars();
  2. myArray = [];
  3. lv.onload = function() {
  4.   myArray[0] = this.A.split("||");
  5.   myArray[1] = this.B.split("||");
  6.   myArray[2] = this.C.split("||");
  7.   myArray[3] = this.D.split("||");
  8.   mysortfunction();
  9. };
  10. lv.load("route.txt");
  11. function mysortfunction() {
  12.   for (var i = 0; i<myArray.length; i++) {
  13.    for (var j = 0; j<myArray[i].length; j++) {
  14.      myArray[i][j] = (myArray[i][j]).split(",");
  15.      trace(myArray[i][j]);
  16.      
  17.    }
  18.   }
  19. }
  20. /*stuck at this portion please help me ...
  21. btn.onPress = function() {
  22.   dot.removeMovieClip();
  23.   myVar = input.text;
  24.   for (var i = 0; i<myArray.length; i++) {
  25.    for (var j = 0; j<myArray[i].length; j++) {
  26.      if ( myVar == myArray[i][j][0]) {
  27.       //trace(myArray[i][j][1]+"_"+myArray[i][j][2])
  28.       showMe(Number(myArray[i][j][1]), Number(myArray[i][j][2]));
  29.       //trace(Number(myArray[i][j][1])+Number(myArray[i][j][2]))
  30.      }else if (myArray[i][j][0].indexOf(myVar) != -1) {
  31.       //output += myArray[i][j][0]+newline;
  32.       trace("Not Found !! At least u know the keywords")
  33.       
  34.      }
  35.    }
  36.   }
  37.   
  38. };
  39. function showMe(x, y) {
  40.   this.attachMovie("dot", "dot", 1);
  41.   dot._x = x;
  42.   dot._y = y;
  43. }
  44. */

and here my dt in textfile //mod edit - single line of vars broken up to prevent post warping
Code: [ Select ]
A=Acircleone%2C320%2C140%7C%7CAcircletwo%2C300%2C110
&B=Bcircleone%2C100%2C200%7C%7CBcircletwo%2C100%2C100%7C%7CBcirclethree%2C100%2C100
&C=Ccircleone%2C100%2C200%7C%7CCcircletwo%2C100%2C100%7C%7CCcirclethree%2C100%2C100
&D=Dcircle
one%2C100%2C200%7C%7CDcircletwo%2C100%2C100%7C%7CDcirclet
hree%2C100%2C100%7C%7CDcirclefour%2C100%2C100
  1. A=Acircleone%2C320%2C140%7C%7CAcircletwo%2C300%2C110
  2. &B=Bcircleone%2C100%2C200%7C%7CBcircletwo%2C100%2C100%7C%7CBcirclethree%2C100%2C100
  3. &C=Ccircleone%2C100%2C200%7C%7CCcircletwo%2C100%2C100%7C%7CCcirclethree%2C100%2C100
  4. &D=Dcircle
  5. one%2C100%2C200%7C%7CDcircletwo%2C100%2C100%7C%7CDcirclet
  6. hree%2C100%2C100%7C%7CDcirclefour%2C100%2C100


so what I after is when user enter the keywords let say "A" and press the search button it will get the dt that stores in array...which is
A=Acircleone,320,140
Acircletwo,300,110
so here,it'll pass this two coordinate("Acircleone(x,y),Acircletwo(x,y)")to attachMC function in order to dynamically placing dotMC to stage...so the result will be two dotMC will dynamically placing to stage accordingly their x,y coordinate..is it possible to achieve it...coz my attemption so far only placing one dotMC only...arghh my head got stuck up please someone can help me out..with this ..
thnks in advanced...and sorry for the long post
  • fifin04
  • Student
  • Student
  • fifin04
  • Posts: 70

Post 3+ Months Ago

Ello...still got no reply...common guys..at least a simply idea might help me to figure out..plsss
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

If it's placing one dot at the right cords then try changing,
Code: [ Select ]
this.attachMovie("dot", "dot", 1);


to somthing like,
Code: [ Select ]
this.attachMovie("dot", "dot"+dots, 100+dots);
dots++;
  1. this.attachMovie("dot", "dot"+dots, 100+dots);
  2. dots++;


It's overwriting the same MC every time that attachMovie gets called right now because it's using the exact same name & depth to create it each time. dots will just be somthing to make unique names for each dot MC.
  • 4ColorZ
  • Newbie
  • Newbie
  • 4ColorZ
  • Posts: 14

Post 3+ Months Ago

that's too complicated....dont have time to analyze your code...why dont you try loading all the values the match it with the input...like load the variables then:
if (inptxt==var1)
{
match
}
something like that...

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 6 guests
  • 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 post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.