Jump to content


Photo

php & XML gallery


  • Please log in to reply
31 replies to this topic

#21 darkson01

darkson01

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Scotland
  • Interests:Gfx, skateboarding, playing guitar, listening to punk music and flash!

Posted 01 February 2007 - 07:02 AM

in your XML file for the gallery, make it so there is only 3 pictures and thumbs, and you will see what i mean.

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 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 01 February 2007 - 10:00 AM

If youre having another swf load up the gallery.swf, it wont work well. _root has been used in the gallery swf. You should try to avoid using _root whenever possible for this very reason.

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 :tiphat:

#23 darkson01

darkson01

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Scotland
  • Interests:Gfx, skateboarding, playing guitar, listening to punk music and flash!

Posted 01 February 2007 - 10:45 AM

ah ok, so ben, if pax's right with the _root thing, what would _root with?

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 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 01 February 2007 - 12:02 PM

Its all about scope, mate. in the gallery swf _root refers to the timeline of Scene1. So whatever movieclip you have thats firing the code, you need to trace its path back to Scene1's timeline.

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 :tiphat:

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 darkson01

darkson01

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Scotland
  • Interests:Gfx, skateboarding, playing guitar, listening to punk music and flash!

Posted 01 February 2007 - 12:23 PM

everything seems to be only on one level below the main timeline, but replacing _root with this._parent, ain't working.

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 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 01 February 2007 - 01:36 PM

Try:

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 darkson01

darkson01

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Scotland
  • Interests:Gfx, skateboarding, playing guitar, listening to punk music and flash!

Posted 01 February 2007 - 02:18 PM

ah ok, i just removed all the _roots and it works fine :)

i had thought about removing them before but i had left the .'s in :P|

thanks for the explaintion on _parents though!

#28 Ben

Ben

    P2L Jedi Master

  • Publishing Betazoids
  • PipPipPipPip
  • 1,366 posts
  • Gender:Male
  • Location:VIC, Australia

Posted 01 February 2007 - 03:47 PM

Lol there could've been a MUCH easier way.. before all the code inside the gallery, add:
_lockroot = true


#29 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

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 Ben

Ben

    P2L Jedi Master

  • Publishing Betazoids
  • PipPipPipPip
  • 1,366 posts
  • Gender:Male
  • Location:VIC, Australia

Posted 02 February 2007 - 12:37 AM

Yeah, I only ever use _root when I have to. I barely ever use it, since I usually put all my code on one frame.

#31 Pax

Pax

    P2L Jedi

  • Members
  • PipPipPip
  • 911 posts
  • Gender:Male
  • Location:Windsor, ON, Canada

Posted 02 February 2007 - 08:48 AM

I use lots of different classes in lots of different projects, so scope is never the same. I *cant* use _root anymore :) Even with lockroot, scope to an object is just never the same.

#32 darkson01

darkson01

    Young Padawan

  • Members
  • Pip
  • 114 posts
  • Gender:Male
  • Location:Scotland
  • Interests:Gfx, skateboarding, playing guitar, listening to punk music and flash!

Posted 18 February 2007 - 04:49 PM

hey ben, you know that XML gallery you gave me, the one that grabs the images from a database and stuff, well i'm wanting it to grab text the same way it grabs the images and the text to be displayed in a simple text field. you have any idea how to do that?

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