I have a simple question i used the Photo Gallery Using XML and Flash tutorial that a modify to fill my needs. So I want to load it into my main movies ( I have a main movie with button which load different movie clip.) This main movie is in as3 and the tutorial is in as2. Does it matter because right now. The flash player alone does run the movie but not the xml, in the browser it load the first image but the button doesn’t work( it always reload the first clicked image.)
Thx for your help
main script code
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.Stage;
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("web.swf"));
l.x=240;
l.y=60;
l.scaleX =l.scaleY = 0.8;
function done(e:Event):void
{
addChild(l);
}
//--- resizefunction resizeDisplay(event:Event):void{
var swfWidth:int = myStage.stageWidth;
var swfHeight:int = myStage.stageHeight;
var txt_copyrightYPos:Number = swfHeight - txt_copyright.height;
var menu2YPOS:Number = swfHeight - menu2.height;
var menu2XPOS:Number = swfWidth - menu2.width;
var transbarBGYpos:Number = swfHeight - transbarBg.height;
var ratio:Number = 360*swfHeight/510;
var scaleratio:Number= swfHeight/510;
var menubaseYpos = (swfHeight/2)-(menubase.height/2);
var texteXpos:Number= 240*scaleratio;
//var texteW:Number = texte.width;
var spareX:Number = (swfWidth/2) - (sparemore.width/2);
bg.height = swfHeight;
bg.width = ratio;
bg.x = 0;
bg.y = 0
transbarBg.width = swfWidth;
transbarBg.y = transbarBGYpos;
txt_copyright.y = txt_copyrightYPos;
menu2.y = menu2YPOS;
menu2.x = menu2XPOS;
menubase.y = menubaseYpos;
if (stage.width<= 65){
sparemore.alpha = 1;
sparemore.x = spareX;
sparemore.y = menubaseYpos;
}
else {
sparemore.alpha = 0;
}
}
myStage.addEventListener(Event.RESIZE, resizeDisplay);
//--- end resize
var swf;
function designerMOUSE_OVER(event:MouseEvent):void {
this.menubase.menu_mc.designer_mc.gotoAndPlay(2);
}
function creationMOUSE_OVER(event:MouseEvent):void {
this.menubase.menu_mc.creation_mc.gotoAndPlay(2);
}
function serviceMOUSE_OVER(event:MouseEvent):void {
this.menubase.menu_mc.service_mc.gotoAndPlay(2);
}
function conseilMOUSE_OVER(event:MouseEvent):void {
this.menubase.menu_mc.conseil_mc.gotoAndPlay(2);
}
function contactMOUSE_OVER(event:MouseEvent):void {
this.menubase.menu_mc.contact_mc.gotoAndPlay(2);
}
menubase.designer_btn.addEventListener(MouseEvent.MOUSE_OVER, designerMOUSE_OVER);
menubase.creation_btn.addEventListener(MouseEvent.MOUSE_OVER, creationMOUSE_OVER);
menubase.service_btn.addEventListener(MouseEvent.MOUSE_OVER, serviceMOUSE_OVER);
menubase.conseil_btn.addEventListener(MouseEvent.MOUSE_OVER, conseilMOUSE_OVER);
menubase.contact_btn.addEventListener(MouseEvent.MOUSE_OVER, contactMOUSE_OVER);
function designerMOUSE_OUT(event:MouseEvent):void {
this.menubase.menu_mc.designer_mc.gotoAndStop(1);
}
function creationMOUSE_OUT(event:MouseEvent):void {
this.menubase.menu_mc.creation_mc.gotoAndStop(1);
}
function serviceMOUSE_OUT(event:MouseEvent):void {
this.menubase.menu_mc.service_mc.gotoAndStop(1);
}
function conseilMOUSE_OUT(event:MouseEvent):void {
this.menubase.menu_mc.conseil_mc.gotoAndStop(1);
}
function contactMOUSE_OUT(event:MouseEvent):void {
this.menubase.menu_mc.contact_mc.gotoAndStop(1);
}
menubase.designer_btn.addEventListener(MouseEvent.MOUSE_OUT, designerMOUSE_OUT);
menubase.creation_btn.addEventListener(MouseEvent.MOUSE_OUT, creationMOUSE_OUT);
menubase.service_btn.addEventListener(MouseEvent.MOUSE_OUT, serviceMOUSE_OUT);
menubase.conseil_btn.addEventListener(MouseEvent.MOUSE_OUT, conseilMOUSE_OUT);
menubase.contact_btn.addEventListener(MouseEvent.MOUSE_OUT, contactMOUSE_OUT);
function designerCLICK(event:MouseEvent):void {
this.mask_mc.gotoAndPlay(2);
swf = "pdesigner.swf";
}
function creationCLICK(event:MouseEvent):void {
this.mask_mc.gotoAndPlay(2);
swf = "pcreation.swf";
}
function serviceCLICK(event:MouseEvent):void {
this.mask_mc.gotoAndPlay(2);
swf = "pservice.swf";
}
function conseilCLICK(event:MouseEvent):void {
this.mask_mc.gotoAndPlay(2);
swf = "pconseil.swf";
}
function contactCLICK(event:MouseEvent):void {
this.mask_mc.gotoAndPlay(2);
swf = "pcontact.swf";
}
menubase.designer_btn.addEventListener(MouseEvent.CLICK, designerCLICK);
menubase.creation_btn.addEventListener(MouseEvent.CLICK, creationCLICK);
menubase.service_btn.addEventListener(MouseEvent.CLICK, serviceCLICK);
menubase.conseil_btn.addEventListener(MouseEvent.CLICK, conseilCLICK);
menubase.contact_btn.addEventListener(MouseEvent.CLICK, contactCLICK);
stop();
Gallery ( web.swf) code:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
thumbnails = [];
thumbs= [];
img = [];
_global.total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
thumbnails* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
thumbnailer(i);
}
firstImage();
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad =loadXML;
xmlData.load("print.xml");
/////////Load First Image Function///////////////////////////////////////////////
/////////Image Preloader Function//////////////////////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = true;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
//////////Load clicked thumbnail Image Function////////////////////////////////////////////////
function callImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
if (p != null){
thumbnail2_mc.thl0.imgl.unloadMovie();
thumbnail2_mc.thl1.imgl.unloadMovie();
thumbnail2_mc.thl2.imgl.unloadMovie();
thumbnail2_mc.thl3.imgl.unloadMovie();
thumbnail2_mc.thl4.imgl.unloadMovie();
thumbnail2_mc.thl5.imgl.unloadMovie();
picture2.unloadMovie();
}
}
detail();
}
//////////Thumbnail maker///////////////////////////////
function thumbnailer(k){
loaded_counter=0;
total_thumbs = _global.total;
var container = thumbnail_mc.createEmptyMovieClip("th"+k,thumbnail_mc.getNextHighestDepth());
container._visible=false;
container._alpha=0;
var image = container.createEmptyMovieClip("img", container.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc.pictureValue = k;
target_mc.onRelease = function() {
p = this.pictureValue;
callImage();
};
target_mc.onRollOver = function() {
this._alpha = 50;
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
loaded_counter++;
if(loaded_counter==total_thumbs){
grid_maker_01();
}
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.th"+k+".img");
}
///////////Layout Functions/////////////////////////////////////////////////////////////////////
MovieClip.prototype.grid_maker_01=function(f){
num=0;
col=1;
row=14;
scale=100;
space=5;
for (l=0;l<row;l++){
for (j=0;j<col;j++){
if(num<_global.total){
with(eval("this.thumbnail_mc.th"+num)){
_x=((_width+space)*scale/100)*l;
_y=((_height+space)*scale/100)*j;
_xscale=_yscale=scale;
_visible=true;
}
num++;
}
}
}
this.cascader();
}
//////////////////////////////////////////////////////////////////////////////////
MovieClip.prototype.cascader=function(){
inter=300;
c=0;
delayed_fade=function(){
if (c<_global.total){
with(eval("this.thumbnail_mc.th"+c)){
fadein();
}
c++;
}else{
main_menu.boton_reset._visible=true;
clearInterval(delay);
}
}
delay=setInterval(delayed_fade,inter);
}
///////////////////////////////////////////////////////////////////////////////
MovieClip.prototype.fadein=function(){
this.onEnterFrame=function(){
if (this._alpha<100){
this._alpha=this._alpha+5;
}else{
this._alpha=100;
delete this.onEnterFrame;
}
}
}
///////////////////////////////////////////////////////////////////////////////////////
MovieClip.prototype.positioner = function(xDest,yDest,rDest,aDest){
this.onEnterFrame=function(){
this._x = xDest-(xDest-this._x)/1.2;
this._y = yDest-(yDest-this._y)/1.2;
this._alpha = aDest-(aDest-this._alpha)/1.2;
this._rotation = rDest-(rDest-this._rotation)/1.2;
if((Math.abs(xDest-this._x) <= 1)and(Math.abs(yDest-this._y) <= 1)){
delete this.onEnterFrame;
this._x = xDest;
this._y = yDest;
this._alpha = aDest;
this._rotation = rDest;
}
}
}
//// detail /////
function detail (){
_global.totall = xmlNode.childNodes[p].childNodes[3].childNodes.length;
for (z=0; z<totall; z++) {
thumbs[z] = xmlNode.childNodes[p].childNodes[3].childNodes[z].childNodes[1].firstChild.nodeValue;
img[z] = xmlNode.childNodes[p].childNodes[3].childNodes[z].childNodes[0].firstChild.nodeValue;
trace(img[z]);
trace(thumbs[z]);
thumbnailer2(z);
}
}
//////////Thumbnail2 maker///////////////////////////////
function thumbnailer2(w){
loaded_counterl=0;
total_thumbsl = _global.totall;
var containerl = thumbnail2_mc.createEmptyMovieClip("thl"+w,thumbnail2_mc.getNextHighestDepth());
containerl._visible=false;
containerl._alpha=0;
var imagel = containerl.createEmptyMovieClip("imgl", containerl.getNextHighestDepth());
tlistenerl = new Object();
tlistenerl.onLoadInit = function(targetl_mc) {
targetl_mc.pictureValue = w;
targetl_mc.onRelease = function() {
q = this.pictureValue;
callImagel();
};
targetl_mc.onRollOver = function() {
this._alpha = 50;
};
targetl_mc.onRollOut = function() {
this._alpha = 100;
};
loaded_counterl++;
if(loaded_counterl==total_thumbsl){
grid_maker_02();
trace("thumb ok");
}
};
imagel_mcl = new MovieClipLoader();
imagel_mcl.addListener(tlistenerl);
imagel_mcl.loadClip(thumbs[w], "thumbnail2_mc.thl"+w+".imgl");
trace(thumbs[w]);
}
//// grid 2 ///
///////////Layout Functions/////////////////////////////////////////////////////////////////////
MovieClip.prototype.grid_maker_02=function(f){
num=0;
col=1;
row=6;
scale=100;
space=5;
for (l=0;l<row;l++){
for (j=0;j<col;j++){
if(num<_global.totall){
with(eval("this.thumbnail2_mc.thl"+num)){
_x=((_width+space)*scale/100)*l;
_y=((_height+space)*scale/100)*j;
_xscale=_yscale=scale;
_visible=true;
}
num++;
}
}
}
this.cascaderl();
trace("grid ok");
}
MovieClip.prototype.cascaderl=function(){
inter=300;
o=0;
delayed_fade=function(){
if (o<_global.totall){
with(eval("this.thumbnail2_mc.thl"+o)){
fadein2();
}
o++;
}else{
main_menu.boton_reset._visible=true;
clearInterval(delay);
}
}
delay=setInterval(delayed_fade,inter);
trace ("cascade ok");
}
MovieClip.prototype.fadein2=function(){
this.onEnterFrame=function(){
if (this._alpha<100){
this._alpha=this._alpha+5;
}else{
this._alpha=100;
delete this.onEnterFrame;
}
}
trace ("fadeinok");}
MovieClip.prototype.positioner = function(xDest,yDest,rDest,aDest){
this.onEnterFrame=function(){
this._x = xDest-(xDest-this._x)/1.2;
this._y = yDest-(yDest-this._y)/1.2;
this._alpha = aDest-(aDest-this._alpha)/1.2;
this._rotation = rDest-(rDest-this._rotation)/1.2;
if((Math.abs(xDest-this._x) <= 1)and(Math.abs(yDest-this._y) <= 1)){
delete this.onEnterFrame;
this._x = xDest;
this._y = yDest;
this._alpha = aDest;
this._rotation = rDest;
}
}
trace ("position ok");}
//////////Load clicked thumbnail Image Function////////////////////////////////////////////////
function callImagel() {
filesize2 = picture2.getBytesTotal();
loaded2 = picture2.getBytesLoaded();
if (loaded2 != filesize2) {
preloader.preload_bar._xscale = 100*loaded2/filesize2;
} else {
preloader._visible = true;
if (picture2._alpha<100) {
picture2._alpha += 10;
}
}
picture2.loadMovie(img[q], 1);
trace ("thumbnail2_mc");
}