php & XML gallery
#21
Posted 01 February 2007 - 07:02 AM
instead of disppearing in the middle, i woudl like it to disppear when it reaches the right hand side.
also when i load the galllery.swf into a fla movie, the thumbs load up fine from the database, but the big pictures don't :s whats up with that?
#22
Posted 01 February 2007 - 10:00 AM
When a swf gets loaded into another, _root changes to the parent swf. Hope that helps a bit. If thats not the problem is, then I dont know what you mean
#23
Posted 01 February 2007 - 10:45 AM
pax is there anything i can replace _root with so it still works and will work when the .swf is loaded into the .fla?
Edited by darkson01, 01 February 2007 - 11:45 AM.
#24
Posted 01 February 2007 - 12:02 PM
Example:
lets say the path to your mc was: _level0.myClip_mc.animation_mc
inside animation_mc on the last frame you had the code _root.gotoAndPlay("animationComplete");
you would need to replace that with this._parent._parent.gotoAndPlay("animationComplete");
"this" refers to the current mc that is executing the code, being animation_mc
"_parent" is the mc that containts "this"
in this case that is myClip_mc
The _parent of myClip_mc is _level0 or _root.
Hope that is sortof clear....think of it as a family tree...with grandparents and children and grandchildren. And for the sake of this analogy, we are thankful Flash doesnt let you put movieclips inside themselves
I'm heading out for lunch now, but ill check the forums again in 1.5 hrs or so...ill have a quick look at teh code too if you dont get the scoping by then.
Good luck mate.
#25
Posted 01 February 2007 - 12:23 PM
var myXML:XML = new XML();var numVar:Number = 0;myXML.ignoreWhite = true;myXML.onLoad = function(success:Boolean) { if(success) { totalImages = myXML.childNodes[0].childNodes.length; for(var i=0; i<totalImages; i++) { _root.imageLoader.loadMovie(myXML.childNodes[0].childNodes[numVar].attributes["image"]); newName = "thumbMc"+i; myThumb = myXML.childNodes[0].childNodes[i].attributes["thumb"]; mouseScroller.attachMovie("thumbMc", newName, i); if(mouseScroller[newName].thumbHold.getBytesLoaded() == mouseScroller[newName].thumbHold.getBytesTotal()) { mouseScroller[newName].loadMc.nextFrame(); } mouseScroller[newName]._x = (mouseScroller[newName]._width+8)*i; mouseScroller[newName].thumbHold.loadMovie(myThumb); mouseScroller[newName].thumbBtn.onRollOver = function() { this.onEnterFrame = function() { this.nextFrame(); } } mouseScroller[newName].thumbBtn.onRollOut = function() { this.onEnterFrame = function() { this.prevFrame(); } } mouseScroller[newName].thumbBtn.onReleaseOutside = function() { this.onEnterFrame = function() { this.prevFrame(); } } mouseScroller[newName].thumbBtn.i = i; mouseScroller[newName].thumbBtn.onRelease = function() { _root.flashTran.gotoAndPlay(1); _root.numVar = this.i; _root.imageLoader.loadMovie(myXML.childNodes[0].childNodes[this.i].attributes["image"]); _root.imageLoader._x = (Stage.width/2)-(_root.imageLoader._width/2); } mouseScroller2.attachMovie("thumbMc", newName, i); if(mouseScroller2[newName].thumbHold.getBytesLoaded() == mouseScroller2[newName].thumbHold.getBytesTotal()) { mouseScroller2[newName].loadMc.nextFrame(); } mouseScroller2._x = mouseScroller._x-((mouseScroller2[newName]._width+5)*(i+1)); mouseScroller2[newName]._x = (mouseScroller2[newName]._width+8)*i; mouseScroller2[newName].thumbHold.loadMovie(myThumb); mouseScroller2[newName].thumbBtn.onRollOver = function() { this.onEnterFrame = function() { this.nextFrame(); } } mouseScroller2[newName].thumbBtn.onRollOut = function() { this.onEnterFrame = function() { this.prevFrame(); } } mouseScroller2[newName].thumbBtn.onReleaseOutside = function() { this.onEnterFrame = function() { this.prevFrame(); } } mouseScroller2[newName].thumbBtn.i = i; mouseScroller2[newName].thumbBtn.onRelease = function() { _root.flashTran.gotoAndPlay(1); _root.numVar = this.i; _root.imageLoader.loadMovie(myXML.childNodes[0].childNodes[this.i].attributes["image"]); } if(_root.imageLoader.getBytesLoaded() == _root.imageLoader.getBytesTotal()) { imgLoadMc.nextFrame(); } nextBtn.onRelease = function() { _root.flashTran.gotoAndPlay(1); if(numVar >= (totalImages-1)) { numVar = 0; } else { numVar++; } _root.imageLoader.loadMovie(myXML.childNodes[0].childNodes[numVar].attributes["image"]); } prevBtn.onRelease = function() { _root.flashTran.gotoAndPlay(1); if(numVar <= 0) { numVar = (totalImages-1); } else { numVar--; } _root.imageLoader.loadMovie(myXML.childNodes[0].childNodes[numVar].attributes["image"]); } } }}_root.onEnterFrame = function() { _root.imageLoader._x = (Stage.width/2)-(_root.imageLoader._width/2); var mousePos:Number = ((_xmouse-scrollArea._x)-(scrollArea._width/2))/50; mouseScroller._x -= mousePos; mouseScroller2._x -= mousePos; if(mouseScroller._x >= 0) { mouseScroller2._x = mouseScroller._x-mouseScroller._width; } else if(mouseScroller._x < (scrollArea._x-mouseScroller._width+scrollArea._width)) { mouseScroller2._x = mouseScroller._x+mouseScroller._width; } if(mouseScroller2._x >= 0) { mouseScroller._x = mouseScroller2._x-mouseScroller2._width; } else if(mouseScroller2._x < (scrollArea._x-mouseScroller2._width+scrollArea._width)) { mouseScroller._x = mouseScroller2._x+mouseScroller2._width; }}myXML.load("gallery.XML");
thats the code there if you want to have a look at it
#26
Posted 01 February 2007 - 01:36 PM
trace(this) in a few spots. See what comes up, it will give you the path to that object so you know how many _parents you need to get back to _level0. If it returns somthing other than a path to a movieclip, it would be because its in the function of an onLoadInit or somthing along those lines, in which case "this" refers to the object/listener onLoadInit is applied to, which can really throw off your scope.
with the trace, its a good idea to trace the object name prior to this so you know what it is. Also good because if it doesnt trace anything for whatever reason, youll know about it. use trace("Element name: " + this);
hope that helps abit.
#27
Posted 01 February 2007 - 02:18 PM
i had thought about removing them before but i had left the .'s in |
thanks for the explaintion on _parents though!
#28
Posted 01 February 2007 - 03:47 PM
_lockroot = true
#29
Posted 01 February 2007 - 04:10 PM
Lol there could've been a MUCH easier way.. before all the code inside the gallery, add:
_lockroot = true
I know that but its better coding practice to not use _root. Same with on(rollOver) type stuff. It all still works but its best not to use it. If I'm going to help people, I'll try and do it so they can learn it properly (not that I know or follow all the standards myself...but).
#30
Posted 02 February 2007 - 12:37 AM
#31
Posted 02 February 2007 - 08:48 AM
#32
Posted 18 February 2007 - 04:49 PM
i've had a go to see if i could do it myself but it won't load up anything from the XML file, not even the thumb pics.
my attempt's below:
var myXML:XML = new XML();var numVar:Number = 0;myXML.ignoreWhite = true;myXML.onLoad = function(success:Boolean) { if(success) { totalImages = myXML.childNodes[0].childNodes.length; for(var i=0; i<totalImages; i++) { imageLoader.loadMovie(myXML.childNodes[0].childNodes[numVar].attributes["image"]); newName = "thumbMc"+i; myThumb = myXML.childNodes[0].childNodes[i].attributes["thumb"]; mouseScroller.attachMovie("thumbMc", newName, i); if(mouseScroller[newName].thumbHold.getBytesLoaded() == mouseScroller[newName].thumbHold.getBytesTotal()) { mouseScroller[newName].loadMc.nextFrame(); } mouseScroller[newName]._x = (mouseScroller[newName]._width+8)*i; mouseScroller[newName].thumbHold.loadMovie(myThumb); mouseScroller[newName].thumbBtn.onRollOver = function() { this.onEnterFrame = function() { this.nextFrame(); } } mouseScroller[newName].thumbBtn.onRollOut = function() { this.onEnterFrame = function() { this.prevFrame(); } } mouseScroller[newName].thumbBtn.onReleaseOutside = function() { this.onEnterFrame = function() { this.prevFrame(); } } mouseScroller[newName].thumbBtn.i = i; mouseScroller[newName].thumbBtn.onRelease = function() { flashTran.gotoAndPlay(1); numVar = this.i; imageLoader.loadMovie(myXML.childNodes[0].childNodes[this.i].attributes["image"]); imageLoader._x = (this.Stage.width/2)-(imageLoader._width/2); } mouseScroller2.attachMovie("thumbMc", newName, i); if(mouseScroller2[newName].thumbHold.getBytesLoaded() == mouseScroller2[newName].thumbHold.getBytesTotal()) { mouseScroller2[newName].loadMc.nextFrame(); } mouseScroller2._x = mouseScroller._x-((mouseScroller2[newName]._width+5)*(i+1)); mouseScroller2[newName]._x = (mouseScroller2[newName]._width+8)*i; mouseScroller2[newName].thumbHold.loadMovie(myThumb); mouseScroller2[newName].thumbBtn.onRollOver = function() { this.onEnterFrame = function() { this.nextFrame(); } } mouseScroller2[newName].thumbBtn.onRollOut = function() { this.onEnterFrame = function() { this.prevFrame(); } } mouseScroller2[newName].thumbBtn.onReleaseOutside = function() { this.onEnterFrame = function() { this.prevFrame(); } } mouseScroller2[newName].thumbBtn.i = i; mouseScroller2[newName].thumbBtn.onRelease = function() { flashTran.gotoAndPlay(1); numVar = this.i; artist.loadMovie(myXML.childNodes[0].childNodes[this.i].attributes["owner"]); file_name.loadMovie(myXML.childNodes[0].childNodes[this.i].attributes["filename"]); imageLoader.loadMovie(myXML.childNodes[0].childNodes[this.i].attributes["image"]); } if(imageLoader.getBytesLoaded() == imageLoader.getBytesTotal()) { imgLoadMc.nextFrame(); } nextBtn.onRelease = function() { flashTran.gotoAndPlay(1); if(numVar >= (totalImages-1)) { numVar = 0; } else { numVar++; } artist.loadMovie(myXML.childNodes[0].childNodes[numVar].attributes["owner"]); file_name.loadMovie(myXML.childNodes[0].childNodes[numVar].attributes["filename"]); imageLoader.loadMovie(myXML.childNodes[0].childNodes[numVar].attributes["image"]); } prevBtn.onRelease = function() { flashTran.gotoAndPlay(1); if(numVar <= 0) { numVar = (totalImages-1); } else { numVar--; } artist.loadMovie(myXML.childNodes[0].childNodes[numVar].attributes["owner"]); file_name.loadMovie(myXML.childNodes[0].childNodes[numVar].attributes["filename"]); imageLoader.loadMovie(myXML.childNodes[0].childNodes[numVar].attributes["image"]); } } }}onEnterFrame = function() { imageLoader._x = (this.Stage.width/2)-(imageLoader._width/2); var mousePos:Number = ((_xmouse-scrollArea._x)-(scrollArea._width/2))/50; mouseScroller._x -= mousePos; mouseScroller2._x -= mousePos; if(mouseScroller._x >= 0) { mouseScroller2._x = mouseScroller._x-mouseScroller._width; } else if(mouseScroller._x < (scrollArea._x-mouseScroller._width+scrollArea._width)) { mouseScroller2._x = mouseScroller._x+mouseScroller._width; } if(mouseScroller2._x >= 0) { mouseScroller._x = mouseScroller2._x-mouseScroller2._width; } else if(mouseScroller2._x < (scrollArea._x-mouseScroller2._width+scrollArea._width)) { mouseScroller._x = mouseScroller2._x+mouseScroller2._width; }}myXML.load("gallery.php");
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users