all groups > flash data integration > may 2007 >
You're in the

flash data integration

group:

loading new image from xml


loading new image from xml dzedward
5/3/2007 4:03:19 PM
flash data integration:
i have an image carousel, images being pulled from xml..right now, when you
click the image, it slides over and some text appears also comming from the
same xml file.. xml set up like this
<?xml version="1.0"?>
<icons>
<icon image="image/Dunne_Lexan.crushed.png" content="Test" />
<icon image="image/Eley,-Howard_Lexan.crushed.png" content="Test" />
<icon image="image/Gagne_Lexan.crushed.png" content="Test" />
<icon image="image/Hackney_Lexan.crushed.png" content="Test" />
<icon image="image/Hastings_Lexan.crushed.png" content="Test" />
<icon image="image/Klee,-Randall_Lexan.crushed.png" content="Test" />
<icon image="image/Rasmussen_Lexan.crushed.png" content="Test" />
<icon image="image/Snyder,-Chris_Lexan.crushed.png" content="Test" />
</icons>

what I would like to happen, is when the user clicks the image, and it slides
over, I want a new image to appear from the same xml file
here is my AS



var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function() {
var nodes = this.firstChild.childNodes;
numOfItem = nodes.length;
for(var i=0; i<numOfItem; i++) {
var t = home.attachMovie("logo", "logo"+i, i+1);
t.angle = i * ((Math.PI*2)/numOfItem);
t.onEnterFrame = mover;
t.content = nodes[i].attributes.content;
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.ref.inner.loadMovie(nodes[i].attributes.image);
t.icon.onRollOver = over;
t.icon.onRollOut = out;
t.icon.onRelease = released;
}
}

xml.load("icons.xml");


function released() {

for(var i=0; i<numOfItem; i++) {
var t:MovieClip = home["logo"+i];
t.xPos = t._x;
t.yPos = t._y;
t.theScale = t._xscale;
delete t.icon.onRollOver;
delete t.icon.onRollOut;
delete t.icon.onRelease;
delete t.onEnterFrame;
if(t != this._parent) {
var tw:Tween = new Tween(t, "_xscale", Strong.easeOut,t._xscale, 0, 1,
true);
var tw2:Tween = new Tween(t, "_yscale", Strong.easeOut,t._yscale, 0, 1,
true);
var tw3:Tween = new Tween(t, "_alpha", Strong.easeOut,100, 0, 1, true);
} else {
var tw:Tween = new Tween(t, "_xscale", Strong.easeOut,t._xscale, 100, 1,
true);
var tw2:Tween = new Tween(t, "_yscale", Strong.easeOut,t._yscale, 100, 1,
true);
var tw3:Tween = new Tween(t, "_x", Strong.easeOut,t._x, 100, 1, true);
var tw4:Tween = new Tween(t, "_y", Strong.easeOut,t._y, 320, 1, true);
var tw5:Tween = new Tween(theText, "_alpha", Strong.easeOut, 0, 100, 1,
true);
theText.text = t.content;
var s:Object = this;
tw.onMotionStopped = function() {
s.onRelease = unReleased;
}


}
}
}

function unReleased() {
delete this.onRelease;
var tw:Tween = new Tween(theText, "_alpha", Strong.easeOut,100, 0, .5,
true);
for(var i=0; i<numOfItem; i++) {
var t:MovieClip = home["logo"+i];
if(t != this._parent) {
var tw:Tween = new Tween(t, "_xscale", Strong.easeOut,0, t.theScale, 1,
true);
var tw2:Tween = new Tween(t, "_yscale", Strong.easeOut,0, t.theScale, 1,
true);
var tw3:Tween = new Tween(t, "_alpha", Strong.easeOut,0, 100, 1, true);
} else {
var tw:Tween = new Tween(t, "_xscale", Strong.easeOut,100, t.theScale, 1,
true);
var tw2:Tween = new Tween(t, "_yscale", Strong.easeOut,100, t.theScale, 1,
true);
var tw3:Tween = new Tween(t, "_x", Strong.easeOut,t._x, t.xPos, 1, true);
var tw4:Tween = new Tween(t, "_y", Strong.easeOut,t._y, t.yPos, 1, true);
tw.onMotionStopped = function() {
for(var i=0; i<numOfItem; i++) {

var t:MovieClip = home["logo"+i];
t.icon.onRollOver = Delegate.create(t.icon,over);
t.icon.onRollOut = Delegate.create(t.icon,out);
t.icon.onRelease = Delegate.create(t.icon,released);
t.onEnterFrame = mover;
}
}


}
}

}

function mover() {
this._x = Math.cos(this.angle) * radiusX + centerX;
this._y = Math.sin(this.angle) * radiusY + centerY;
var s:Number = new Number();
s = (this._y-perspective)/(centerY+radiusY-perspective);
this._xscale = this._yscale = s*100;
this.angle += this._parent.speed;
this.swapDepths(Math.round(this._xscale)+100);
}

this.onMouseMove = function() {
speed = (this._xmouse-centerX)/14000;
}
Re: loading new image from xml dzedward
5/4/2007 3:16:58 PM
bump
AddThis Social Bookmark Button