|
-
Bmcc*81
XML + URLS: Carousel
Hi,
I'm having some trouble with my carousel.
They all link to the same place. I have different links but they go to the same spot.
Here's my xml.load function:
PHP Code:
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.toolText = nodes[i].attributes.tooltip;
t.urlRef = nodes[i].attributes.link;
t.content = nodes[i].attributes.content;
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.r.inner.loadMovie(nodes[i].attributes.image);
t.icon.onRollOver = over;
t.icon.onRollOut = out;
t.icon.onRelease = released;
}
};
Launch URL Button:
PHP Code:
launch_magazine_mc.onRelease = function() {
// trace(this._parent.urlRef);
getURL(this._parent.urlRef, "_self");
};
and they all launch the same URL all the time.
Can someone Help?
DOWNLOAD FILE HERE (if needed)
Thanks,
-
Bmcc*81
Can anyone tell me why it launches the same page from my XML FILE
This is the last thing I need to finish my project, the help would be appreciated.
Thanks,
-
you need to store the info in an Array. I may be wrong, but it looks like you are just looping through your xml. So your variable will always equal the last URL in your xml.
IMS
-
Bmcc*81
Thanks
Would I just make the array like this?
var urlRef:Array = new Array();
Thanks
-
-
Bmcc*81
This is what I ended up doing. I made the array at the top.
PHP Code:
var urlRef = new Array();
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);
var w = home.attachMovie("item", "item"+i, i+1);
t.angle = i*((Math.PI*2)/numOfItems);
t.onEnterFrame = mover;
t.toolText = nodes[i].attributes.tooltip;
urlRef[i] = nodes[i].attributes.URLREF;
/*for (var j = 0; j=numLinks; j++){
}*/
links = urlRef;
//var url = xml.firstChild.firstChild.childNodes[i].attributes.URLREF;
t.content = nodes[i].attributes.content;
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.r.inner.loadMovie(nodes[i].attributes.image);
t.icon.onRollOver = over;
t.icon.onRollOut = out;
t.icon.onRelease = released;
}
};
launch_magazine_mc.onRelease = function() {
var _index = 0; // this is the (zero-based) index of the url you need. for the second url set this to 1, the next would be 2 etc...
trace(urlRef[_index]);
getURL(urlRef[_index], "_self");
};
This now gives me the first url in the array. I need it to recognize which icon is selected and what url that's selected.
Thanks,
-
this is going to be hard to explain, I tried to oopen your file, but got a zip error.
So basically, you are setting up a bunch of buttons, and depending on what button you push, an image changes, and you are sent to a specific link? Are the buttons being created dynamicaly, or are they all static on the stage?
-
Bmcc*81
Hi and thanks,
there is one button on the stage that is static it is called Basically your right with everything else. If you could help me figure this out it would be excellent.
DOWNLOAD FILES HERE
Thanks,
-
Ok, so if you click the button, you will go to the first link, if you click it again, you will go to the second, and so on?
you are almost there, try:
PHP Code:
var _index = 0;
launch_magazine_mc.onRelease = function() {
trace(urlRef[_index]);
getURL(urlRef[_index], "_self");
_index ++;
}
you want to put your variable outside of the button code. the way you have it, everytime you press the button, _index is going to equal 0. I added _index++ to the button code. everytime you press the button, this will increase _index by 1, therfore scrolling through your array.
Last edited by IMS; 02-24-2009 at 05:22 PM.
-
Bmcc*81
Nope it depends what Icons is selected
Not really it really depends on what icon is selected. The code that yo gave me just goes through like a picture gallery.
It has to know what numOfItems it is on.
Thanks,
-
If there is only one button, how do we set what Icon is showing?
-
Bmcc*81
Set icons with this...
It works with using this
PHP Code:
for (var i = 0; i<numOfItems; i++) {
var t:MovieClip = home["item"+i];
I use it in the released(); of my code:
PHP Code:
function released() {
//BONUS Section
var sou:Sound = new Sound();
sou.attachSound("sdown");
sou.start();
home.tooltip._alpha = 0;
for (var i = 0; i<numOfItems; i++) {
var t:MovieClip = home["item"+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, 73, 1, true);
var tw4:Tween = new Tween(t, "_y", Strong.easeOut, t._y, 195, 1, true);
var tw5:Tween = new Tween(theText, "_alpha", Strong.easeOut, 0, 100, 1, true);
var tw:Tween = new Tween(launch_magazine_mc, "_xscale", Strong.easeOut, 0, 100, 1, true);
var tw2:Tween = new Tween(launch_magazine_mc, "_yscale", Strong.easeOut, 0, 100, 1, true);
var tw5:Tween = new Tween(launch_magazine_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);
theText.text = t.content;
var s:Object = this;
tw.onMotionStopped = function() {
s.onRelease = unReleased;
};
}
}
}
Hope that explains
-
not really, It's hard to visualize without seeing it. Is there a way to find out what the image is?
-
Bmcc*81
I think it's...
PHP Code:
var t:MovieClip = home["item"+i];
That tells you what Item your on.
You can download the files now I've fixed the link
-
I think I got this:
replace the following: (I commented what I added with my initials so it is easy to find)
(added: myCurrentCover = t.myLink
PHP Code:
function released() {
trace('released')
//BONUS Section
var sou:Sound = new Sound();
sou.attachSound("sdown");
sou.start();
home.tooltip._alpha = 0;
for (var i = 0; i<numOfItems; i++) {
var t:MovieClip = home["item"+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, 73, 1, true);
var tw4:Tween = new Tween(t, "_y", Strong.easeOut, t._y, 195, 1, true);
var tw5:Tween = new Tween(theText, "_alpha", Strong.easeOut, 0, 100, 1, true);
var tw:Tween = new Tween(launch_magazine_mc, "_xscale", Strong.easeOut, 0, 100, 1, true);
var tw2:Tween = new Tween(launch_magazine_mc, "_yscale", Strong.easeOut, 0, 100, 1, true);
var tw5:Tween = new Tween(launch_magazine_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);
theText.text = t.content;
var s:Object = this;
myCurrentCover = t.myLink; //this will set what mag cover was clicked. IMS
tw.onMotionStopped = function() {
s.onRelease = unReleased;
};
}
}
}
replace:
(added: t.myLink = nodes[i].attributes.URLREF; )
PHP Code:
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);
var w = home.attachMovie("item", "item"+i, i+1);
t.angle = i*((Math.PI*2)/numOfItems);
t.onEnterFrame = mover;
t.toolText = nodes[i].attributes.tooltip;
t.myLink = nodes[i].attributes.URLREF; // set link to specified movie clip (t) IMS
t.content = nodes[i].attributes.content;
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.r.inner.loadMovie(nodes[i].attributes.image);
t.icon.onRollOver = over;
t.icon.onRollOut = out;
t.icon.onRelease = released;
trace('link: '+ t.myLink);
}
//trace('urlRef: '+ urlRef);
}
REPLACE:
PHP Code:
launch_magazine_mc.onRelease = function() {
trace('myCurrentCover: '+ myCurrentCover); // this should be the cover that was clicked.. IMS
getURL(myCurrentCover, "_self");
}
Hopefully this works. I basically started tracing everyting to see how it all worked. then set a variable after you click a cover. then I new what cover was clicked. then I just placed that variable in the URL.
IMS
-
Bmcc*81
Wow,
You made it look so simple. It makes perfect sense. Thanks, I got it working.
You da man!!!
-
No problem.
Glad it worked.
IMS
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|