with XML in web applications, allowing you to access it with any application. The following tutorial will show how to combine Flash with actionscript with XML to create a web page

actionscript frame one

  1. var pager=3;
  2. var nextVar=0;
  3. local=function(){
  4. var myXML:XML = new XML();
  5. myXML.ignoreWhite=true;
  6. myXML.load("page.xml");
  7. myXML.onLoad = function(success) {
  8.     if (success) {
  9.         var depth = 0;
  10.         var nextX = 90;
  11.        count = 0;
  12.        var myWeb = myXML.firstChild.childNodes;
  13.        for (i=nextVar; i<;pager; i++) {
  14.        if (myWeb.length==pager){
  15.        next_btn._visible=false;
  16.         }
  17. if (nextVar==0){
  18.        prev_btn._visible=false;
  19. }else{
  20. prev_btn._visible=true;
  21. }
  22. var pageNumber = i+1;
  23. var titlePost = myWeb[i].attributes.title;
  24. tempMC = attachMovie ("page", "page" + count, depth ++, {_y : (168) , _x : (nextX)} );
  25. tempMC.onRollOver=function(){
  26. this.gotoAndStop(2);
  27. }
  28. tempMC.onRollOut=function(){
  29. this.gotoAndStop(1);
  30. }
  31. tempMC.onRelease=function(){
  32. postTitle.text=this.titlepost_text.text;
  33. i=this.pagetext.text;
  34. post.text=myWeb[i-1].firstChild.nodeValue;
  35. local();
  36. }
  37. nextX += tempMC._width + 2;
  38. tempMC.titlepost_text.text=titlePost;
  39. tempMC.pagetext.text = pageNumber;
  40. count ++;
  41. }
  42. }
  43. }
  44. };
  45. local();
Actionscript on next button
  1. on(release){
  2. pager+=1;
  3. nextVar+=1;
  4. local();
  5. }
Actionscript on Prev button
  1. on(release){
  2. pager-=1;
  3. nextVar-=1;
  4. next_btn._visible=true;
  5. local();
  6. }
pager.xml
  1. <post>
  2. <pager title="XML">XML simple</pager>
  3. <pager title="blog">blog endless love</pager>
  4. <pager title="PHP">php my love</pager>
  5. <pager title="HTML">start</pager>
  6. <pager title="Ajax">powerfull</pager>
  7. </post>
click here  for download sample


No comments:

Post a Comment