all groups > flash data integration > october 2006 >
You're in the

flash data integration

group:

XML Problem (Likely an EASY fix)


XML Problem (Likely an EASY fix) KTULKevin
10/19/2006 5:29:23 PM
flash data integration:
I've been working on a flash video player in which icons float in a circular
motion around a large video window. When you click on one of the floating
icons, I want that video to play in the large window. The whole thing reads
from an xml file to get the images inside the icons as well as what videos to
play:

<icons>
<icon image="icon1.jpg" url="promo1.flv" />
<icon image="icon2.jpg" url="promo2.flv" />
AND SO ON.....
</icons>

The following is the part of my actionscript that is giving me the problem.
Everything loads fine and looks great. But, when you get down to the part where
it says ns.play("http://......, in the testing phase it gives me "Error opening
URL "http://www.ktul.com/static/videos/undefined"". I'm sure it's because it's
inside a function. But, I don't know what I can do to make it work. You can
view this thing in action at http://www.ktul.com/static/newcarousel.swf. Any
ideas?

MY ACTIONSCRIPT:

var numOfItems:Number;
var radiusX:Number = Stage.width/2;
var radiusY:Number = Stage.height/3;
var centerX:Number = Stage.width/2;
var centerY:Number = Stage.height/2;
var speed:Number = 0.05;
var perspective:Number = 130;
var home:MovieClip = this;

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
theVideo.attachVideo(ns);

var xml:XML = new XML();
xml.ignoreWhite = true;

xml.onLoad = function()
{
var nodes = this.firstChild.childNodes;
numOfItems = nodes.length;
for (var i=0;i<numOfItems;i++)
{
var t = home.attachMovie("item","item"+i,i+1);
t.angle = i * ((Math.PI*2)/numOfItems);
t.onEnterFrame = mover;
t.icon_mc.loadMovie("http://www.ktul.com/static/"+nodes[i].attributes.image);
t.onPress = function()
{
ns.play("http://www.ktul.com/static/videos/"+attributes.url);
}
}
}

xml.load("http://www.ktul.com/static/icons.xml");

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

this.onMouseMove = function()
{
speed = (this._xmouse-centerX)/5500;
}

Thanks for any help.
Kevin
Re: XML Problem (Likely an EASY fix) The Feldkircher
10/20/2006 12:00:00 AM
Hi

So you're using the now familiar Lee Brimelow Carousel, OK this function I
understand. So it seems strange that your building


t.icon_mc.loadMovie(".attributes.image);">http://.attributes.image);]http://www.
ktul.com/static/"+nodes<">http://www.ktul.com/static/"+nodes[i

which seems over complicated to me, only my opinion though.

Why not simplify the whole load sequence by placing the entire target in the
xml url, then all you have to do is

t.icon.movietoplay = nodes[i].attributes.url

then you can pass this ( t.onPress = function() ) to the Netstream
connection

t.onPress = function()
{
for (var i=0;i<numofItems;i++)
{
var t:MovieClip = home["item"+i];
if ( t == this._parent){
ns.play(t.icon.movietoplay)
}
}
}

I've not tried this but it seems logical to me that once the video as been
targeted then the player should work

Hope it helps
AddThis Social Bookmark Button