Hola a todos encontré una solución a mi problema, pero cuando la aplico en mi fla no me funciona y creo que e seguido los pasos al pie de la letra, este es el ActionScript de la solución el componente esta instanciado como stak
/* In order for this to work right, I created 3 blank MCs for a hitTest() detection. instance names are: hitLeft, hitRight, mouseTest hitLeft should be placed on the stage to the left and covering the photoFlow Stack hitRight the same but to the right mouseTest is a draggable mc that is used for the detection. */
mouseTest.startDrag(true); var dir:String; // this will be used to set the direction.. see below. //create array for each value var urlAry:Array = new Array(); var linkAry:Array = new Array(); /* I couldn't figure how to use the description in between the tags, so I created a separate descrip tag inside my XML for the description */ var descAry:Array = new Array(); var nameAry:Array = new Array();
// grab XML data for array var xml:XML = new XML(); xml.ignoreWhite = true; xml.load("photos.xml"); //enter the name of your external XML here xml.onLoad = parse; function parse(success){ if(success){ root = xml.firstChild; _global.numberOfItems = root.attributes.items; itemNode = root.firstChild; var i = 0; while (itemNode != null){ nameAry.push(itemNode.attributes.name); urlAry.push(itemNode.attributes.url); linkAry.push(itemNode.attributes.link); descAry.push(itemNode.attributes.descrip); // descrip is the name of my description tag as mentioned above
itemNode = itemNode.nextSibling; i++; } } else{ trace("XML Failed."); }
}
var inst={}; inst.onInitPhotoFlow=function(evt){ _root.og = stak.getTotal(); // variable holds the original number of items _root.dun = _root.og; //variable sets the starting point } stak.addEventListener ("onInitPhotoFlow", inst);
function onselect(){ var eventListener:Object = new Object(); eventListener.onSelectPhoto = function(eventObject:Object){ if(hitRight.hitTest(mouseTest)){ clickforward(); _root.dir = "right"; } else if(hitLeft.hitTest(mouseTest)){ clickback(); _root.dir = "left"; } else if(_root.dir == "left"){ clickback(); } else if(_root.dir == "right"){ clickback(); } } stak.addEventListener("onSelectPhoto", eventListener); }
m = 0;
function clickforward(){ tot = stak.getTotal(); if (stak.getSelectedIndex() >= (tot - 2)){ stak.addPhoto({name:nameAry[m], url:urlAry[m], link:linkAry[m], descrip:descAry[m]}, tot+1); m++; if(m >(og-1)){m = 0;} } }
function clickback(){ curri = stak.getSelectedIndex(); if(curri <= 1){ dang = dun - 1; tot = stak.getTotal(); stak.addPhoto({name:nameAry[dang], url:urlAry[dang], link:linkAry[dang], descrip:descAry[dang]}, 0); dun--; //decrement the dun variable if(dang == 0 ){dun = og;} } }
// button on the stage that control the movement. I did not use the scrollbar for this example.
clkrt.onPress = function(){ stak.flipNext(); _root.dir = "right"; clickforward(); }
clklt.onPress = function(){ stak.flipBack(); _root.dir = "right"; clickback(); }
Este es el mio.
/* In order for this to work right, I created 3 blank MCs for a hitTest() detection. instance names are: hitLeft, hitRight, mouseTest hitLeft should be placed on the stage to the left and covering the photoFlow Stack hitRight the same but to the right mouseTest is a draggable mc that is used for the detection. */
mouseTest.startDrag(true); var dir:String; // this will be used to set the direction.. see below. //create array for each value var urlAry:Array = new Array(); var linkAry:Array = new Array(); /* I couldn't figure how to use the description in between the tags, so I created a separate descrip tag inside my XML for the description */ var descAry:Array = new Array(); var nameAry:Array = new Array();
// grab XML data for array var xml:XML = new XML(); xml.ignoreWhite = true; xml.load("migallery.xml"); //enter the name of your external XML here xml.onLoad = parse; function parse(success){ if(success){ root = xml.firstChild; _global.numberOfItems = root.attributes.items; itemNode = root.firstChild; var i = 0; while (itemNode != null){ nameAry.push(itemNode.attributes.name); urlAry.push(itemNode.attributes.url); linkAry.push(itemNode.attributes.link); // descrip is the name of my description tag as mentioned above
itemNode = itemNode.nextSibling; i++; } } else{ trace("XML Failed."); }
}
var inst={}; inst.onInitPhotoFlow=function(evt){ _root.og = PRESSHOW.getTotal(); // variable holds the original number of items _root.dun = _root.og; //variable sets the starting point } PRESSHOW.addEventListener ("onInitPhotoFlow", inst);
function onselect(){ var eventListener:Object = new Object(); eventListener.onSelectPhoto = function(eventObject:Object){ if(hitRight.hitTest(mouseTest)){ clickforward(); _root.dir = "right"; } else if(hitLeft.hitTest(mouseTest)){ clickback(); _root.dir = "left"; } else if(_root.dir == "left"){ clickback(); } else if(_root.dir == "right"){ clickback(); } } PRESSHOW.addEventListener("onSelectPhoto", eventListener); }
m = 0;
function clickforward(){ tot = PRESSHOW.getTotal(); if (PRESSHOW.getSelectedIndex() >= (tot - 2)){ PRESSHOW.addPhoto({name:nameAry[m], url:urlAry[m], link:linkAry[m], descrip:descAry[m]}, tot+1); m++; if(m >(og-1)){m = 0;} } }
function clickback(){ curri = PRESSHOW.getSelectedIndex(); if(curri <= 1){ dang = dun - 1; tot = PRESSHOW.getTotal(); PRESSHOW.addPhoto({name:nameAry[dang], url:urlAry[dang], link:linkAry[dang], descrip:descAry[dang]}, 0); dun--; //decrement the dun variable if(dang == 0 ){dun = og;} } }
// button on the stage that control the movement. I did not use the scrollbar for this example.
clkrt.onPress = function(){ PRESSHOW.flipNext(); _root.dir = "right"; clickforward(); }
clklt.onPress = function(){ PRESSHOW.flipBack(); _root.dir = "right"; clickback(); }
Quisiera saber porque no me funciona...
|
Por CLAnonimo
Claber
600 de clabLevel
5 tutoriales
1 articulo
Envíale un mensaje privado Web
|