Basically I found a pretty basic flash photo gallery. I'm new to XML, Flash, and Actionscripts so I wasn't really sure what I was doing. The template didn't come with a caption for the pictures so I added a dynamic text box and attempted to use AS. Basically I was trying to make it when you moused over the picture the caption appeared with the text from the XML files. All I can get to come up is undefined. Here is my AS script, what I added is in red so the problem is probably around it.
AlsoCode:photo_thumbnail = new Array(); photo_url = new Array(); photo_caption = new Array(); filepath = "photos/"; var flash_xml = new XML(); flash_xml.ignoreWhite = true; flash_xml.onLoad = function() { var node:Array = this.firstChild.childNodes; for(var i=0;i<nodes.length;i++) { photo_thumbnail.push(nodes[i].attributes.thumbnail); photo_url.push(nodes[i].attributes.url); photo_caption.push(nodes[i].attributes.caption); } } flash_xml.load(filepath + "flash_thumbnails.xml"
Finally the XMLCode:x_middle = Stage.width/2; y_middle = Stage.height/2; tn_group.tn._visible = false; tn_group.setMask( tn_area ); tn_alpha_default = 100; tn_spacing = 6; p = 0; info = ""; desc = ""; for( var i = 0; i < photo_thumbnail.length; i++ ) { tn_group.tn.duplicateMovieClip("tn"+i, i); tn_group["tn"+i].tn_pic.loadMovie( filepath + photo_thumbnail[i] ); tn_group["tn"+i].tn_pic2.loadMovie( filepath + photo_thumbnail[i] ); tn_group["tn"+i]._x = i * (tn_group.tn._width + tn_spacing); tn_group["tn"+i]._y = tn._y; tn_group["tn"+i].tn_pic._alpha = tn_alpha_default; tn_group["tn"+i].tn_no = i; tn_group["tn"+i].tn_button.onRollOver = function() { this._parent.tn_pic._alpha = 70; _root.info = photo_url[this._parent.tn_no]; _root.desc = photo_caption[this._parent.tn.no]; } tn_group["tn"+i].tn_button.onRollOut = function() { this._parent.tn_pic._alpha = tn_alpha_default; _root.info = ""; _root.desc = ""; } tn_group["tn"+i].tn_button.onRelease = function() { getURL( photo_url[this._parent.tn_no] ); } } onEnterFrame = function() { if( _ymouse > tn_group._y - 30 and _ymouse < tn_group._y + tn_group._height ) { x_speed = -(_xmouse - x_middle ) / 50; if( _xmouse > x_middle + 200 ) { if( tn_group._x + tn_group.tn._width > tn_area._width - tn_group._width + tn_area._x ) tn_group._x+=x_speed; } else if( _xmouse < x_middle - 200 ) { if( tn_group._x - tn_group.tn._width < tn_area._x ) tn_group._x+=x_speed; } } }
Any ideas why it is coming up with Undefined when I mouseover a picture?Code:<?xml version="1.0" encoding="utf-8"?> <photos> <photo thumbnail="flashmo_028_design.jpg" url="http://www.google.com" caption="insert caption" /> <photo thumbnail="flashmo_029_design.jpg" url="http://www.google.com" caption="insert caption" /> <photo thumbnail="flashmo_030_design.jpg" url="http://www.google.com" caption="insert caption" /> <photo thumbnail="flashmo_031_mask_effect.jpg" url="http://www.google.com" caption="insert caption" /> <photo thumbnail="flashmo_032_mask_effect.jpg" url="http://www.google.com" caption="insert caption" /> <photo thumbnail="flashmo_033_design.jpg" url="http://www.google.com" caption="insert caption" /> <photo thumbnail="flashmo_034_photo_gallery.jpg" url="http://www.google.com" caption="insert caption" /> <photo thumbnail="flashmo_035_color_effect.jpg" url="http://www.google.com" caption="insert caption" /> <photo thumbnail="flashmo_036_skyblue.jpg" url="http://www.google.com" caption="insert caption" /> <photo thumbnail="flashmo_037_wooden.jpg" url="http://www.google.com" caption="insert caption" /> </photos>




Reply With Quote