all groups > flash actionscript > april 2007 >
You're in the

flash actionscript

group:

xml help


xml help dzedward
4/24/2007 10:11:49 PM
flash actionscript:
I have images being pulled from a xml file and they spin around according to
the cursor like a carousel, however, when i click one of the images, i have it
set so all the others disappear and it brings up a Media Display...I'd like to
put corresponding videos there from a xml file as well... how do i go about
doing this so it pulls the right movie according to the image???
Re: xml help dzedward
4/25/2007 4:09:25 AM
Re: xml help Rothrock
4/25/2007 5:24:48 AM
What have you learned in the last day on this issue?

What do you mean how do you go about this? You do what you said. You need
someway of hooking up the clip you clicked on with which video you want to
show. So you can either put the FLV filenames into your original XML. Or if
there are several different FLVs for each images perhaps you need to put the
name of that XML in your first XML and then load that XML when you click on an
image.

I'm not quite following exactly how your project is set up.
Re: xml help dzedward
4/25/2007 2:19:59 PM
[q]You need someway of hooking up the clip you clicked on with which video you
want to show.[/q]
correct

[q]So you can either put the FLV filenames into your original XML[/q]
how do i put them in along with the image, so that each flv is attached to its
corresponding image?

<?xml version="1.0"?>
<icons>
<icon image="image/Dunne_Lexan.png"/>
<icon image="image/Eley,-Howard_Lexan.png"/>
<icon image="image/Gagne_Lexan.png" />
<icon image="image/Hackney_Lexan.png" />
<icon image="image/Hastings_Lexan.png"/>
<icon image="image/Klee,-Randall_Lexan.png"/>
<icon image="image/Rasmussen_Lexan.png"/>
<icon image="image/Snyder,-Chris_Lexan.png"/>
<icon image="image/Steckle,-Larry_Lexan.png"/>
<icon image="image/Torres,-Jack_Lexan.png"/>
<icon image="image/Crumley_Lexan.png" />
<icon image="image/Chung_Lexan.png"/>
<icon image="image/Buckles_Lexan.png"/>
<icon image="image/Buchholz_lexan.png"/>
<icon image="image/Brooks_Lexan.png"/>
<icon image="image/Beall_Lexan.png"/>
<icon image="image/Bailey_Lexan.png"/>
<icon image="image/Anderson,-Bill_Lexan.png"/>
<icon image="image/Alexander,-Lyn_Lexan.png"/>
</icons>


Re: xml help Rothrock
4/25/2007 3:34:07 PM
An easy way would be:

<icon image="image/Brooks_Lexan.png" video="video/Brooks_Lexan.flv"/>

However that only attaches it to that node in your XML, at some point where
you are loading in the images or such you will either need to get the video
attribute and put it into a property in the clip, or have some way of looking
up which node the image came from and matching up the video attribute.

Are you making an array when you load in the XML or just keep it as an XML
object?

Re: xml help dzedward
4/25/2007 3:42:24 PM
this is what ive got so far, as you can see, all images load 'Anderson.swf' im
just not familiar with xml and getting the data from it.
[q]<icon image="image/Brooks_Lexan.png" video="video/Brooks_Lexan.flv"/>[/q]
thats what i have, but i have them pulling SWF files of the flv

import mx.utils.Delegate;
import mx.transitions.Tween;
import mx.transitions.easing.*;


var numOfItem:Number = new Number();
var radiusX:Number = new Number();
var radiusY:Number = new Number();
var centerX:Number = new Number();
var centerY:Number = new Number();
var speed:Number = new Number();
var perspective:Number = new Number();
var home:MovieClip = new MovieClip();
home = this;
//numOfItem = 12;
radiusX = 400;
radiusY = 75;
centerX = Stage.width/2;
centerY = (Stage.height/3);
speed = 0.045;
perspective = 120;
theText._alpha = 0;



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.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() {

trace(loadMovie("Anderson.swf", medDisp)
);
medDisp._x=400
medDisp._y=100
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 s:Object = this;
tw.onMotionStopped =
function() {
s.onRelease =
unReleased;
}


}
}
}

function unReleased() {
delete this.onRelease;
trace(unloadMovie(medDisp));
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;
Re: xml help dzedward
4/25/2007 6:49:09 PM
Re: xml help Rothrock
4/26/2007 3:14:08 PM
I'm sorry, there is a lot of code there and because you pasted it into the body
of a message all the [ someletter ] (where someletter=i) messed up the
formatting. If you are going to put code in a post, use the attach code button.
That keeps all the formatting and all.

That being said, that is a lot of code to wade through. After a quick look as
best I can, it seems that you are assigning an angle property to "t" you can
also assign something like this:

t.movieToLoadOnClick=nodes.attributes.video

Then when you click on that icon you would just need to use the variable:

whateverTarget.loadMovie(this.movieToLoadOnClick);

I would suggest setting aside this project for a brief moment and just
learning how to work with XML a bit. Start with a brand new Flash file and
maybe just three nodes in a shorter xml file. Play with it a bit and get to
know XML without the complications of all the other stuff. When you come back
to this it will be a lot easier.



AddThis Social Bookmark Button