Guest User

Untitled

a guest
Jan 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. public function initXML() {
  2.  
  3. var _URL:URLRequest = new URLRequest("../xml/portfolio.xml");
  4. infoXML.load(_URL);
  5. infoXML.dataFormat = URLLoaderDataFormat.TEXT;
  6. infoXML.addEventListener(Event.COMPLETE, xmlLoaded);
  7.  
  8. }//end function
  9.  
  10. public function xmlLoaded(evt:Event):void{
  11. ImageXml = new Array();
  12.  
  13. _XML = new XML(evt.target.data);
  14. var lista:XMLList = _XML.file;
  15.  
  16. total = lista.length() -1;
  17.  
  18. for(var i:Number = 0; i < lista.length();i++){
  19. var obj: Object = new Object();
  20. obj = lista[i].@path;
  21. ImageXml.push(obj);
  22.  
  23.  
  24. }//end for
  25.  
  26. addImage();
  27.  
  28. }// end function
  29.  
  30. public function addImage():void {
  31.  
  32. imgAtual = ImageXml[nextImage];
  33. image = new MovieClip;
  34.  
  35. with(image){
  36. x = posX;
  37. useHandCursor = true;
  38. mouseChildren = false;
  39. buttonMode = true;
  40.  
  41. }
  42.  
  43. loadImage = new Loader();
  44. loadImage.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
  45. loadImage.load(new URLRequest(ImageXml[nextImage]));
  46.  
  47. addChild(image);
  48. recebeImg.addChild(image);
  49.  
  50. //TERIA QUE EXISTIR UM FOR, ALGO QUE FICASSE PEGANDO A IMAGEM ATUAL AO RECEBER O CLIQUE.
  51.  
  52. //this.addEventListener(MouseEvent.CLICK, clicaImage, false, 0 , false);
  53. //var clicaImage:Function = function(evt:MouseEvent){atual(imgAtual)};
  54. }
  55.  
  56. public function onComplete(evt:Event):void {
  57.  
  58. image.addChild(loadImage);
  59.  
  60. proxImage();
  61.  
  62. }//end function
  63.  
  64. public function proxImage() {
  65.  
  66. if(nextImage >= total){
  67. nextImage = 0;
  68. posX = 0;
  69.  
  70. }//end if
  71. else{
  72. nextImage += 1;
  73. posX += 500;
  74. addImage();
  75.  
  76. }//end else
  77.  
  78.  
  79. }//end function
Add Comment
Please, Sign In to add comment