here's the final code:
------------------------------------------------------------------------
var speed:Number = 1.5;
var picSpace:Number = 120;
var basexmlfeed:String =
'http://csdev.ilsemedia.nl/Wegaanwinnen.nl/data/media/_shared/swf/thuistribune.php';
var picturePath:String =
'http://csdev.ilsemedia.nl/Wegaanwinnen.nl/data/media/tribunes/thuis/';
var picHeight = 90;
var picWidth = 108;
//if(_root.PictureID){
// lul_txt.text = picId;
//xmlfeed = basexmlfeed + '?PictureID=' + _root.PictureID;
//} else {
xmlfeed = basexmlfeed;
//}
var currentPic = -1;
var xml:XML = new XML();
var pictures:Array = new Array();
var picFileNames:Array = new Array();
var picIds:Array = new Array();
var ids:Array = new Array();
function pictureScroll() {
for (i in pictures) {
pictures[i]._x += speed;
if (pictures[i]._x-1>((pictures.length-1)*picSpace)) {
pictures[i]._x -= ((pictures.length)*picSpace);
}
if (pictures[i]._x > 260 and pictures[i]._x < 360 and
currentPic!=i) {
currentPic = i;
var listener:Object = new Object();
var mcLoader = new MovieClipLoader();
listener.onLoadInit = middlePicLoaded;
mcLoader.addListener(listener);
mcLoader.loadClip(picFileNames[i],
_root.middlePicture_mc.middlePic_mc);
}
}
}
function loadXML() {
xml.load(xmlfeed);
xmlObj.ignoreWhite = true;
xml.onLoad = xmlLoaded;
}
function picLoaded(mc) {
mc._width = picWidth;
mc._height = picHeight;
}
function middlePicLoaded(mc) {
mc._width = 196;
mc._height = 153;
}
function xmlLoaded(success:Boolean) {
import mx.xpath.XPathAPI;
if (success) {
nodes = XPathAPI.selectNodeList(xml.lastChild,
'feed/picture/file/*');
ids = XPathAPI.selectNodeList(xml.lastChild, 'feed/picture/id/*');
for (i in nodes) {
var listener:Object = new Object();
listener.onLoadInit = picLoaded;
var mcLoader = new MovieClipLoader();
mcLoader.addListener(listener);
newPic =
pictureScrollContainer.picture_mc.duplicateMovieClip('node'+i,
pictureScrollContainer.getNextHighestDepth());
mcLoader.loadClip(picturePath + nodes[i].toString(), newPic);
newPic._alpha = 100;
id = pictures.push(newPic);
picFileNames.push(picturePath + nodes[i].toString());
newPic._x = id * picSpace;
}
_root.onEnterFrame = pictureScroll;
}
}
_root.next_btn.onRelease = function(){
trace(ids[0]);
}
_root.prev_btn.onRelease = function(){
var picId: Number;
picId = parseInt(ids[0]) - 10;
xmlfeed = basexmlfeed + '?PictureID=' + picId;
for(i in pictures){
with(eval("_level0.pictureScrollContainer.node" + i)){
removeMovieClip();
}
pictures.shift();
picFileNames.shift();
}
loadXML();
}
pictureScrollContainer.picture_mc._alpha = 0;
loadXML();
------------------------------------------------------------------------
Cheers,
Siep
Martin Weiser schreef:
so i had to rewrite the button's attached function. Problem solved,
but now i can't come up with a decent explanation
for why it didnt work in the first place.
state changed, the function could work for the first time,
show us the code better
MW
----- Original Message ----- From: "Sibrand Hoekstra | Buyways B.V."
<[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <[email protected]>
Sent: Wednesday, April 05, 2006 2:19 PM
Subject: Re: [Flashcoders] loading updated XML
Thanks everybody for taking the time, i have been able to fix the
problem after the lunch. =)
I was lucky to have written a bad loop, crashing my flash IDE and
therefore not saving my unsaved work,
so i had to rewrite the button's attached function. Problem solved,
but now i can't come up with a decent explanation
for why it didnt work in the first place.
Yes, Eric, the php file was written pretty well, except my
actionscript wasn't ;)
Siep
Éric Thibault schreef:
I you call your php page directly from your browser does it return
the desired XML file? And with your ID parameter?
A+
Sibrand Hoekstra wrote:
Hello list,
First off, hi all. I subscribed to this list yesterday and ive seen
alot of good posts already, so there's little doubt that anyone can
help me out ;)
A little introduction:
Since a few weeks i'm hired at an Internet Development company in
town, and my job is primarily xhtml/css development.
Yet, the very first project I am doing requires a jpg-viewer flash
app. Last week ive been studying books, and code of friends to
build what i am building right now, and one of the final steps has
got me stuck.
so, here we are:
[actionscript is in the bottom of this email]
I am making a flash movie that loads 10 jpeg files from a xml feed,
generated by a phpfile.
Its purpose is to act as a carrousel that loops the jpegs over the
screen.
The feed shows the last 10 uploaded jpegs if no parameters are set.
If you pass it a parameter called PictureID, it'll give you the
jpeg with the given ID plus the 9 jpegs uploaded prior to that.
(ie. feed.php?PictureID=20)
i am having php echo the given PictureID to html as in this:
<params name="flashvars" value="PictureID=20">
in the actionscript i am retrieving that with _root.PictureID.
Next step is to load the 10 jpegs that come before(10-1) the
curently(20-11) loaded jpegs.
And here i am having trouble, please checkout the function attached
to the button, in the bottom of the script.
First i'm emptying the arrays and unloading currently loaded jpegs.
I then want to reset the PictureID to 10 lower than the current
value and 'start all over again' with the new range of jpegs.
Except, at 'loadXML' nothing happens.
So can anyone please help me, or give any insights on how this
should be solved?
[p.s. i could also do a getURL() to the page itself and pass the
feed.php a new parameter, but we dont want to make it look smooth.. ]
Many thanks in advance,
Sibrand Hoekstra
----------------------------------------------------------------------------------------------------------------------------------------
var speed:Number = 1.5;
var picSpace:Number = 120;
var xmlfeed:String = 'feed.php';
var picturePath:String = 'path/to/picturefolders/;
var picHeight = 90;
var picWidth = 108;
if(_root.PictureID){
xmlfeed = xmlfeed + '?PictureID=' + _root.PictureID;
}
var currentPic = -1;
var xml:XML = new XML();
var pictures:Array = new Array();
var picFileNames:Array = new Array();
var picIds:Array = new Array();
function pictureScroll() {
for (i in pictures) {
pictures[i]._x += speed;
if (pictures[i]._x-1>((pictures.length-1)*picSpace)) {
pictures[i]._x -= ((pictures.length)*picSpace);
}
if (pictures[i]._x > 260 and pictures[i]._x < 360 and
currentPic!=i) {
currentPic = i; var listener:Object =
new Object();
var mcLoader = new MovieClipLoader();
listener.onLoadInit = middlePicLoaded;
mcLoader.addListener(listener);
mcLoader.loadClip(picFileNames[i],
re_mc.middlePic_mc); }
}
}
function loadXML() {
xml.load(xmlfeed);
xmlObj.ignoreWhite = true;
xml.onLoad = xmlLoaded;
}
function picLoaded(mc) {
mc._width = picWidth;
mc._height = picHeight;
}
function middlePicLoaded(mc) {
mc._width = 196;
mc._height = 153;
}
function xmlLoaded(success:Boolean) {
import mx.xpath.XPathAPI;
if (success) { nodes =
XPathAPI.selectNodeList(xml.lastChild, 'feed/picture/file/*'); ids
= XPathAPI.selectNodeList(xml.lastChild, 'feed/picture/id/*');
for (i in nodes) {
var listener:Object = new Object();
listener.onLoadInit = picLoaded;
var mcLoader = new MovieClipLoader();
mcLoader.addListener(listener);
newPic =
pictureScrollContainer.picture_mc.duplicateMovieClip('node'+i,
pictureScrollContainer.getNextHighestDepth());
mcLoader.loadClip(picturePath + nodes[i].toString(),
newPic);
newPic._alpha = 100;
id = pictures.push(newPic);
picFileNames.push(picturePath + nodes[i].toString());
newPic._x = id * picSpace;
}
_root.onEnterFrame = pictureScroll; }
}
pictureScrollContainer.picture_mc._alpha = 0;
loadXML();
_root.prev_btn.onRelease = function(){
_level0.pictureScrollContainer.unloadMovie();
_level0.middlePicture_mc.unloadMovie();
for(i in pictures){
pictures.shift(); picFileNames.shift();
} trace(_root.PictureID);
set("_root.PictureID", (_root.PictureID - 10));
trace(_root.PictureID);
loadXML();
trace('hmm');
}
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com