Go Back   kirupaForum > Flash > ActionScript 1.0/2.0

Reply
 
Thread Tools Display Modes
Old 09-23-2009, 12:10 PM   #1
Galland
Registered User
 
Galland's Avatar
XML links to load AS2 swf

Hello

Here is my AS2/XML question - I think it has a fairly straightforward solution, but I'm quite new to XML!

I'm using an AS2 carousel loaded as an swf into an AS3 page - no problem there.

The AS2 files loads PNG icons that have XML links set to load external URLs.

I'd like to somehow alter the XML file so that instead of the links loading external URLs, when clicked they load swf files back into the AS2 file.

Hope this is clear - below I've included the AS2 code for the carousel and the XML code.

These files are from xuroqflash.com - an excellent resource site, but a little difficult to get support from!

Any help with this problem is greatly appreciated!

Here's the AS2 code:

import mx.utils.Delegate;
//set variables
var numOfItems:Number;
var radiusX:Number = 240;
var radiusY:Number = 95;
var centerX:Number = 550;
var centerY:Number = 300;
var speed:Number = 0.1;
var perspective:Number = 150;
var home:MovieClip = this;
//load XML shhet(images)
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.url = nodes[i].attributes.url;
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.r.inner.loadMovie(nodes[i].attributes.image);
t.icon.onRelease = released;
}
}
//on release function
function released()
{
getURL(this._parent.url);
}
xml.load("icons.xml");
//tells how the carousel should interact to mouse
function mover()
{
this._x = Math.cos(this.angle) * radiusX + centerX;
this._y = Math.sin(this.angle) * radiusY + centerY;
var 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);
}
//speed of movement
this.onMouseMove = function()
{
speed = (this._xmouse-centerX)/4500;
}

And here's the XML:

<icons>
<icon image="icon1.png" url="http://limewire.com" />
<icon image="icon2.png" url="http://adobe.com/products/fireworks" />
<icon image="icon3.png" url="http://adobe.com/products/flash" />
<icon image="icon4.png" url="http://adobe.com/products/photoshop" />
<icon image="icon5.png" url="http://adobe.com/products/dreamweaver/ "/>
</icons>

I've tried naming the url to eg. url="about.swf" target="_self" but I don't think that's the answer!

Can anyone help? Much obliged, Galland
Galland is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 09-24-2009, 07:38 PM   #2
thirdcherry
Registered User
you're linking not loading...

Hi there,

you're making a getURL call in your link to the URL. this is how you get an external link.

If you want to load a .swf into the current movie, you'll need to update your icon code to load a movie. You'll want to make a container for your movie to be loaded into. then do something like below:

function released()
{
// getURL(this._parent.url);

yourContainer.loadMovie(nodes[i].attributes.url);

}

Quote:
Originally Posted by Galland View Post
Hello

Here is my AS2/XML question - I think it has a fairly straightforward solution, but I'm quite new to XML!

I'm using an AS2 carousel loaded as an swf into an AS3 page - no problem there.

The AS2 files loads PNG icons that have XML links set to load external URLs.

I'd like to somehow alter the XML file so that instead of the links loading external URLs, when clicked they load swf files back into the AS2 file.

Hope this is clear - below I've included the AS2 code for the carousel and the XML code.

These files are from xuroqflash.com - an excellent resource site, but a little difficult to get support from!

Any help with this problem is greatly appreciated!

Here's the AS2 code:

import mx.utils.Delegate;
//set variables
var numOfItems:Number;
var radiusX:Number = 240;
var radiusY:Number = 95;
var centerX:Number = 550;
var centerY:Number = 300;
var speed:Number = 0.1;
var perspective:Number = 150;
var home:MovieClip = this;
//load XML shhet(images)
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.url = nodes[i].attributes.url;
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.r.inner.loadMovie(nodes[i].attributes.image);
t.icon.onRelease = released;
}
}
//on release function
function released()
{
getURL(this._parent.url);

}
}
//on release function
function released()
{
getURL(this._parent.url);
}
}
xml.load("icons.xml");
//tells how the carousel should interact to mouse
function mover()
{
this._x = Math.cos(this.angle) * radiusX + centerX;
this._y = Math.sin(this.angle) * radiusY + centerY;
var 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);
}
//speed of movement
this.onMouseMove = function()
{
speed = (this._xmouse-centerX)/4500;
}

And here's the XML:

<icons>
<icon image="icon1.png" url="http://limewire.com" />
<icon image="icon2.png" url="http://adobe.com/products/fireworks" />
<icon image="icon3.png" url="http://adobe.com/products/flash" />
<icon image="icon4.png" url="http://adobe.com/products/photoshop" />
<icon image="icon5.png" url="http://adobe.com/products/dreamweaver/ "/>
</icons>

I've tried naming the url to eg. url="about.swf" target="_self" but I don't think that's the answer!

Can anyone help? Much obliged, Galland
thirdcherry is offline   Reply With Quote
Old 09-25-2009, 01:12 PM   #3
Galland
Registered User
 
Galland's Avatar
Hi Thirdcherry
Thank you, your help is most appreciated - I will give this a shot.
Regards,
Galland
Galland is offline   Reply With Quote
Old 09-28-2009, 03:34 PM   #4
Galland
Registered User
 
Galland's Avatar
Need to specify URL path somewhere?

Hi Thirdcherry

I've adjusted my icon code as advised...


function released()
{
// getURL(this._parent.url);

yourContainer.loadMovie(nodes[i].attributes.url);
}



...and created a movie clip (eg yourContainer) to target my swf into.


But I get the error
Error opening URL 'file:////tsclient/D/files/main/undefined'

Does this mean I have to define a path to the URL within my AS2 code or specify it within my XML code?

My XML code currently lists the URL like this:

<icon image="icon1.png" url="about.swf" />

THANKS! Your help is much appreciated.

Regards,

Galland
Galland is offline   Reply With Quote
Old 09-28-2009, 03:36 PM   #5
Galland
Registered User
 
Galland's Avatar
...or if Thirdcherry isn't available - Bueller... Anybody... Bueller...
Galland is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:19 AM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com