solisarg escribió:
Para ello falta definir algunas cosas en tu pregunta
1. Estás parseando el XML? Como? Si agregas una propiedad con la info que necesitas, se agrega en el parseo el código para recuperarlo
2. Cual es la relación entre el botón y el destino al que quieres llamar? Están en la misma línea de tiempo? Sabés la ruta al destino (_root.holder por ejemplo)
TellTarget no se usa desde Flash 4 ... no se si sigue soportado
Jorge
Este es el codigo que tiene la pelicula que es controlada por el XML:
Código :
//import classes and packages
import mx.transitions.easing.*;
import mx.transitions.Tween;
import flash.geom.ColorTransform;
import flash.geom.Transform;
import com.pixelfumes.Reflect;
stop();
ROOT = _root;
//create a function for changing the color of a movieclip
//function setColor(mc:MovieClip, ct:ColorTransform, t:Transform, a:Number, r:Number, g:Number, b:Number):Void {
ct.alphaOffset = a;
ct.redOffset = r;
ct.greenOffset = g;
ct.blueOffset = b;
t.colorTransform = ct;
//}
//create a function for sorting images by x value in imgArray
//use 2 parametres and returns a number,
//* -1 if the first parameter x is lower then the second x,
//* 1 if the first parameter x is greater then the second x,
//* 0 if both are equal
function order(a:MovieClip, b:MovieClip):Number {
var x1:Number = a._x;
var x2:Number = b._x;
if (x1<x2) {
return -1;
} else if (x1>x2) {
return 1;
} else {
return 0;
}
}
//create a function for infinit scroll,
//if the scroller is moving right, add the right images which are not in the view, on the left side
//if the scroller is moving left, add the left images which are not in the view, on the right side
//then sort the array by x
function infinitScroll() {
if (currentGallX>prevGallX) {
for (i=imgArray.length-1; i>=0; i--) {
if (!imgArray[i].hitTest(scrollArea)) {
imgArray[i]._x = (firstX-imgArray[i]._width);
firstX = imgArray[i]._x;
} else {
break;
}
}
} else if (currentGallX<prevGallX) {
for (i=0; i<imgArray.length; i++) {
if (!imgArray[i].hitTest(scrollArea)) {
imgArray[i]._x = lastX;
lastX = lastX+imgArray[i]._width;
} else {
break;
}
}
}
imgArray.sort(order);
lastX = imgArray[imgArray.length-1]._x+imgArray[imgArray.length-1]._width;
firstX = imgArray[0]._x;
}
//function to add movieclips for loading the images in
function addImages() {
for (i=0; i<obj.images.length; i++) {
imgArray[i] = gallery.attachMovie("imgMC", "imgMC"+i, i);
//get the link for each element
imgArray[i].link = obj.images[i].attributes.link;
//set some dimensions
imgArray[i].textMC.t._width = Number(obj.images[i].attributes.width);
imgArray[i].textMC.t.text = obj.images[i].attributes.description;
if (imgArray[i].textMC.t.text == "undefined") {
imgArray[i].textMC.t.text = "";
}
imgArray[i].textMC._alpha = 0;
imgArray[i].textMC._y = 0;
imgArray[i].clip.back._width = Number(obj.images[i].attributes.width);
imgArray[i].clip.back._height = Number(obj.images[i].attributes.height);
imgArray[i].clip.loading._x = Number(obj.images[i].attributes.width)/2;
imgArray[i].clip.loading._y = Number(obj.images[i].attributes.height)/2;
//position each element
imgArray[i]._x = pushOverX;
pushOverX += Number(obj.images[i].attributes.width);
//add reflection (you can change the paramaters for obtaining a diferent reflection, for fast perfomance let the upateTime set to null)
imgArray[i].clip.r = new Reflect({mc:imgArray[i].clip, alpha:100, ratio:100, distance:5, updateTime:null, reflectionAlpha:30, reflectionDropoff:1});
//add path and loading container to the loadingQueue array
loadingQueue.push({source:obj.images[i].attributes.path, level:imgArray[i].clip.container});
}
gallery._x = 0;
////////////////////////////////////////////////////////////////
//begin loading
startQueue();
}
//create function for image events
function setImageEvents(movieclip:MovieClip) {
movieclip.onRollOver = function() {
//create rollover animation
mc = this._parent._parent;
mc.textMC.tweenAlpha.stop();
mc.textMC.tweenY.stop();
mc.clip.tweenAlpha.stop();
//the tween parameters are changeables for obtaining different results (for example Elastic.easeOut with Bounce.easeOut for a bounce effect,etc)
mc.textMC.tweenAlpha = new Tween(mc.textMC, "_alpha", Strong.easeOut, mc.textMC._alpha, 100, 1, true);
mc.textMC.tweenY = new Tween(mc.textMC, "_y", Elastic.easeOut, mc.textMC._y, -mc.textMC._height, 1, true);
mc.clip.tweenAlpha = new Tween(mc.clip.container, "_alpha", Strong.easeOut, mc.clip.container._alpha, 100, 1, true);
//outline animation
gallery.outline.tweenAlpha.stop();
gallery.outline.tweenWidth.stop();
gallery.outline.tweenHeight.stop();
gallery.outline.tweenX.stop();
gallery.outline.tweenAlpha = new Tween(gallery.outline, "_alpha", None.easeNone, gallery.outline._alpha, 30, .6, true);
gallery.outline.tweenWidth = new Tween(gallery.outline, "_width", Strong.easeOut, gallery.outline._width, mc.clip.container._width, .6, true);
gallery.outline.tweenHeight = new Tween(gallery.outline, "_height", Strong.easeOut, gallery.outline._height, mc.clip.container._height, .6, true);
gallery.outline.tweenX = new Tween(gallery.outline, "_x", Strong.easeOut, gallery.outline._x, mc._x, .6, true);
//show hand cursor
if(handCursorVisible){
Mouse.hide();
ROOT.openHandCursor._visible = true;
ROOT.closeHandCursor._visible = false;
}
//play sound
s.start();
};
movieclip.onRollOut = movieclip.onReleaseOutside=function () {
//create rollout animation
mc = this._parent._parent;
mc.textMC.tweenAlpha.stop();
mc.textMC.tweenY.stop();
mc.clip.tweenAlpha.stop();
//the tween parameters are changeables for obtaining different results
mc.textMC.tweenAlpha = new Tween(mc.textMC, "_alpha", Strong.easeOut, mc.textMC._alpha, 0, .5, true);
mc.textMC.tweenY = new Tween(mc.textMC, "_y", Strong.easeOut, mc.textMC._y, 0, .5, true);
mc.clip.tweenAlpha = new Tween(mc.clip.container, "_alpha", Strong.easeOut, mc.clip.container._alpha, 100, .5, true);
//outline animation
gallery.outline.tweenAlpha.stop();
gallery.outline.tweenAlpha = new Tween(gallery.outline, "_alpha", None.easeNone, gallery.outline._alpha, 0, .6, true);
//hide hand cursor
if(handCursorVisible){
Mouse.show();
ROOT.openHandCursor._visible = false;
ROOT.closeHandCursor._visible = false;
}
//s.stop();
};
movieclip.onPress = function() {
//create variables to store current pressed image, the x and y coordinates of mouse
pressImage = this;
pressX = ROOT._xmouse;
pressY = ROOT._ymouse;
if(handCursorVisible){
Mouse.hide();
ROOT.openHandCursor._visible = false;
ROOT.closeHandCursor._visible = true;
}
};
movieclip.onRelease = function() {
//check if it is click
if (ROOT._xmouse == pressX && ROOT._ymouse == pressY && pressImage.hitTest(ROOT._xmouse, ROOT._ymouse)) {
//trace("click");
link = pressImage._parent._parent.link;
//if the link exists then open the link page
if (link != undefined && link != "" && link != " ") {
getURL(pressImage._parent._parent.link, "_blank");
}
}
if(handCursorVisible){
Mouse.hide();
ROOT.openHandCursor._visible = true;
ROOT.closeHandCursor._visible = false;
}
pressImage = undefined;
};
movieclip.useHandCursor = false;
}
//load first image in queue
function startQueue() {
MCL.loadClip(loadingQueue[0].source,loadingQueue[0].level);
}
function ease() {
//calculate speed per frame
velx = Math.floor((destX-currentGallX)/10);
if (Math.abs(velx)<=minSpeed && direction == "right") {
velx = minSpeed;
destX = currentGallX;
} else if (Math.abs(velx)<=minSpeed && direction == "left") {
velx = -minSpeed;
destX = currentGallX;
}
//add velx to the current position
gallery._x = Math.floor(gallery._x+velx);
}
//create the scrolling functionality
function activateScrolling() {
if (startDirection == "left" || startDirection == "right") {
direction = startDirection;
gallery.onEnterFrame = function() {
//store the x of the last image
lastX = imgArray[imgArray.length-1]._x+imgArray[imgArray.length-1]._width;
//store the x of the first image
firstX = imgArray[0]._x;
currentGallX = gallery._x;
ease();
infinitScroll();
//now assign to the prev the current value
prevGallX = currentGallX;
};
}
mouseListener.onMouseDown = function() {
//exectute if mouse press on gallery
if (scrollArea.hitTest(ROOT._xmouse, ROOT._ymouse)) {
isPress = true;
//drag on horizontal
startDrag(gallery, false, -1000000, gallery._y, 1000000, gallery._y);
//store the x of the last image
lastX = imgArray[imgArray.length-1]._x+imgArray[imgArray.length-1]._width;
//store the x of the first image
firstX = imgArray[0]._x;
prevGallX = gallery._x;
//execute on each frame
gallery.onEnterFrame = function() {
currentXMouse = ROOT._xmouse;
//the mouse x distance from the last frame to the new one
difX = currentXMouse-previousXMouse;
previousXMouse = currentXMouse;
currentGallX = gallery._x;
if (!isPress) {
//call the ease function
ease();
} else {
//get the moving direction
if (difX>0) {
direction = "right";
} else if (difX<0) {
direction = "left";
}
}
//call infinitScroll
infinitScroll();
//now assign to the prev the current value
prevGallX = currentGallX;
};
}
};
mouseListener.onMouseUp = function() {
//exectute if mouse is up on gallery
if (isPress) {
if(difX==0 && stopOnPress){
delete gallery.onEnterFrame;
}else{
//calculete the destination
//(can decrease or increase the number eqaul to 10 to move slower or faster)
destX = gallery._x+10*difX;
}
isPress = false;
gallery.stopDrag();
}
};
mouseListener.onMouseMove = function() {
ROOT.openHandCursor._x = ROOT.closeHandCursor._x = ROOT._xmouse;
ROOT.openHandCursor._y = ROOT.closeHandCursor._y = ROOT._ymouse;
updateAfterEvent();
}
}
//create sound object to load the rollover sound (you can change the path for another sound)
var s:Sound = new Sound();
s.loadSound("clic.mp3");
s.setVolume(100);
//create array for storing images
var imgArray:Array = new Array();
// where to start the placement from
var pushOverX:Number = 0;
//variabile for minimum scrolling speed (this value can be changed)
var minSpeed:Number = 2;
//create a few variables for coordinates
var prevGallX:Number = new Number();
var currentGallX:Number = new Number();
var lastX:Number = new Number();
var firstX:Number = new Number();
var difX:Number = new Number();
var direction:String = new String();
var startDirection:String = new String();
var stopOnPress:Boolean = new Boolean();
ROOT.closeHandCursor._visible = ROOT.openHandCursor._visible = false;
var handCursorVisible:Boolean = new Boolean();
var pressX:Number = new Number();
var pressY:Number = new Number();
var pressImage:MovieClip = new MovieClip();
var isPress:Boolean = false;
//create mouse listener object
var mouseListener:Object = new Object();
Mouse.addListener(mouseListener);
//an array for loading images one by one
var loadingQueue:Array = new Array();
//counter for thumbnails which are loaded
var count:Number = 0;
//create a new MovieClipLoader for loading images
var MCL:MovieClipLoader = new MovieClipLoader();
//create a listener for loading
var listener:Object = new Object();
MCL.addListener(listener);
//object which contains data from xml
var obj:Object = new Object();
//create nex xml object
var xml:XML = new XML();
xml.ignoreWhite = true;
var colorTrans:ColorTransform = new ColorTransform();
colorTrans.rgb = 0xFFFFFF;
var transGradient:Transform = new Transform(ROOT.gradient);
var transBackGround:Transform = new Transform(ROOT.bg);
//after the xml is loaded, parse the date to obj
xml.onLoad = function(succes) {
if (succes) {
startDirection = this.firstChild.attributes.startDirection;
if(this.firstChild.attributes.outlineVisible == "true"){
gallery.attachMovie("outline","outline",10000);
gallery.outline._alpha = 0;
}
if(this.firstChild.attributes.handCursorVisible == "true"){
handCursorVisible = true;
}else{
handCursorVisible = false;
}
if(this.firstChild.attributes.stopOnPress == "true"){
stopOnPress = true;
}else{
stopOnPress = false;
}
maskMC._width = ROOT.bg._width = Number(this.firstChild.attributes.maskWidth);
maskMC._height = ROOT.bg._height = Number(this.firstChild.attributes.maskHeight);
ROOT.gradient._width = Number(this.firstChild.attributes.maskWidth)+80;
ROOT.gradient._height = Number(this.firstChild.attributes.maskHeight);
scrollArea._y = gallery._y;
scrollArea._width = Number(this.firstChild.attributes.scrollAreaWidth);
scrollArea._height = Number(this.firstChild.attributes.scrollAreaHeight);
//trace(startDirection);
colorTrans.rgb = Number(this.firstChild.attributes.bgColor);
a = colorTrans.alphaOffset;
r = colorTrans.redOffset;
g = colorTrans.greenOffset;
b = colorTrans.blueOffset;
//change background color
setColor(ROOT.bg, colorTrans, transBackGround,a,r,g,b);
//change gradient color
setColor(ROOT.gradient, colorTrans, transGradient,a,r,g,b);
obj.images = this.firstChild.childNodes;
addImages();
activateScrolling();
} else {
trace("xml could not load");
}
};
//the path to the xml file
xml.load("trr.xml");
listener.onLoadProgress = function(targetMC:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
targetMC._parent.loading.t.text = Math.floor((bytesLoaded/bytesTotal)*100);
};
listener.onLoadInit = function(targetMC:MovieClip) {
targetMC._alpha = 0;
targetMC.tweenAlpha = new Tween(targetMC, "_alpha", Strong.easeOut, 0, 100, 1, true);
targetMC._parent.loading.tweenAlpha = new Tween(targetMC._parent.loading, "_alpha", Strong.easeOut, 100, 0, 1, true);
targetMC._parent.back.tweenAlpha = new Tween(targetMC._parent.back, "_alpha", Strong.easeOut, 100, 0, 1, true);
targetMC.tweenAlpha.onMotionChanged = function() {
targetMC._parent.r.update(targetMC._parent);
};
delete targetMC._parent.loading.onEnterFrame;
setImageEvents(targetMC);
count++;
if (count<loadingQueue.length) {
//load the next thumbnail from queue
MCL.loadClip(loadingQueue[count].source,loadingQueue[count].level);
}
//all thumbnails have loaded
if (count == loadingQueue.length) {
count = 0;
loadingQueue.length = 0;//everything has loaded so now empty the array
}
};\0
Gracias!!