Log in

View Full Version : fixed size in swf and menu issue



Irishcash33
08-12-2008, 01:07 AM
Hi,
Is there a way to have the swf a fixed size? My stage size is 600w x 500y, but when I export the swf, the window goes as large or small as the browser. I want it and all the contents to be within 600x500. I have tried the allowscale=false. Doesn't work. Here is the swf. (http://www.clashgraphicdesign.com/preview.swf)
Any suggestions?

Menu issue
I moved the menu_mc and nav_mc to the bottom of the stage, where I want it.
For some reason it is still on top in the swf.

Is there something in this code that would be telling it to stay on top?

// INITIAL VARS /////////////////////////////////////////////////////////////////////////////////
// Set stage width and height here
_global.stageW = 600;
_global.stageH = 500;
// Set default gallery here
galleryID = 0;
// Set default page here
page = 1;
// Set max number of thumbnail columns here
maxColumns = 3;
// Set max number of thumbnail rows here
maxRows = 4;
// Set space between thumbnails here
hSpace = 15;
vSpace = 15;
// Set space between category buttons here
menuSpace = 0;
maxThumbs = maxColumns*maxRows;
thumbWidth = item_mc.item._width;
thumbHeight = item_mc.item._height;
imageViewer_mc._visible = false;
nav_mc._visible = false;
menu_all._visible = false;
// ON STAGE RESIZE /////////////////////////////////////////////////////////////////////////////////
nav_mcY = nav_mc._y;
stageListener = new Object(this);
Stage.addListener(stageListener);
alignObjects = function () {
bg._x = -(Stage.width-_global.stageW)/2;
bg._y = -(Stage.height-_global.stageH)/2;
bg._width = Stage.width;
bg._height = Stage.height;
imageViewer_mc.bg._x = -(Stage.width-_global.stageW)/2;
imageViewer_mc.bg._y = -(Stage.height-_global.stageH)/2;
imageViewer_mc.bg._width = Stage.width;
imageViewer_mc.bg._height = Stage.height;
nav_mc._y = Math.round(nav_mcY+(Stage.height-_global.stageH)/2);
nav_mc._x = Math.round((_global.stageW-nav_mc._width)/2);
menu_mc._x = -(Stage.width-stageW)/2;
menu_mc._y = -(Stage.height-stageH)/2;
menu_mc.bg._width = Stage.width;
fullscreen_mc._x = (Stage.width-(Stage.width-stageW)/2)-30;
fullscreen_mc._y = 5-(Stage.height-stageH)/2;
menu_all._y = -(Stage.height-stageH)/2;
menu_all._x = -(Stage.width-stageW)/2+(Stage.width-menu_all._width)/2;
};
stageListener.onResize = function() {
alignObjects();
};
alignObjects();
// BUTTONS FUNCTIONS /////////////////////////////////////////////////////////////////////////////////
pageNum = function () {
nav_mc.pageNumDisplay.text = page+" / "+maxPage;
};
nav_mc.bttnPrev.bttn.onPress = function() {
if (page>1) {
page -= 1;
buildGallery();
}
};
nav_mc.bttnNext.bttn.onPress = function() {
if (page<maxPage) {
page += 1;
buildGallery();
}
};
_global.thumbPress = function(obj) {
imageViewer_mc.destAlpha = 105;
imageViewer_mc._visible = true;
imageViewer_mc.holder._alpha = -100;
imageViewer_mc.galleryID = galleryID;
imageViewer_mc.ID = obj.ID;
imageViewer_mc.loadID();
};
// GENERATE GALLERY /////////////////////////////////////////////////////////////////////////////////
buildGallery = function () {
galleryTotal = xmlNode.childNodes[galleryID].childNodes.length;
totalThumbs = maxThumbs
maxPage = Math.ceil(galleryTotal/maxThumbs);
pageNum();
for (n=0; n<galleryTotal; n++) {
Thumb[n] = xmlNode.childNodes[galleryID].childNodes[n].attributes.Thumb;
Caption[n] = xmlNode.childNodes[galleryID].childNodes[n].attributes.Caption;
Large[n] = xmlNode.childNodes[galleryID].childNodes[n].attributes.Large;
Copy[n] = xmlNode.childNodes[galleryID].childNodes[n].childNodes[0].firstChild.nodeValue;
}
for (i=0; i<maxThumbs; i++) {
num = i+(maxThumbs*page)-maxThumbs;
if (num<galleryTotal) {
item_mc.item.duplicateMovieClip("item"+i, i);
ID = i+(maxThumbs*page)-maxThumbs;
item_mc["item"+i].ID = ID;
item_mc["item"+i]._x = (i%maxColumns)*(hSpace+thumbWidth);
item_mc["item"+i]._y = Math.floor(i/maxColumns)*(vSpace+thumbHeight);
item_mc["item"+i].num.text = ID;
item_mc["item"+i].holder.loadMovie(Thumb[ID]);
item_mc["item"+i].info_mc.txt_mc.txt.text = Caption[ID];
item_mc["item"+i].info_mc.txt_mc.txt._height = item_mc["item"+i].info_mc.txt_mc.txt.textHeight+5;
item_mc["item"+i].info_mc.bg._height = item_mc["item"+i].info_mc.txt_mc.txt._height;
item_mc["item"+i].info_mc._y = thumbHeight-item_mc["item"+i].info_mc.bg._height;
} else {
item_mc["item"+i].removeMovieClip();
}
}
item_mc.item._visible = false;
item_mc._x = Math.round(_global.stageW/2-(((thumbWidth+hSpace)*maxColumns)-hSpace)/2);
item_mc._y = Math.round(_global.stageH/2-(((thumbHeight+vSpace)*maxRows)-vSpace)/2);
};
// LOAD XML /////////////////////////////////////////////////////////////////////////////////
loadXML = function (loaded) {
if (loaded) {
xmlNode = this.firstChild;
total = xmlNode.childNodes.length;
Thumb = [];
Caption = [];
Large = [];
Copy = [];
buildGallery();
for (n=0; n<total; n++) {
menu_all.menu_mc.duplicateMovieClip("menu_mc"+n, n);
menu_all["menu_mc"+n]._x = (menu_all.menu_mc._width+menuSpace)*n;
menu_all["menu_mc"+n].categoryName.text = xmlNode.childNodes[n].attributes.Name;
menu_all["menu_mc"+n].ID = n;
menu_all["menu_mc"+n].num.text = subNum[n];
}
alignObjects();
nav_mc._visible = true
menu_all._visible = true
} else {
trace("Error loading XML");
}
};
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("content.xml");
stop();

Medyman
08-13-2008, 01:20 PM
First, if you're going to be resizing the browser window, you should define the scaleMode (http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary678.html) and alignment (http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary674.html).


Stage.scaleMode = "noScale"
Stage.align = "TL"

Also, the width of the SWF depends on the code you use to embed it. If you view the SWF directly in the browser, it will always expand to fill the window. You should be embedding the SWF into a HTML page. Use SWFObject 2.0 (http://code.google.com/p/swfobject/) to embed.

If you want your nav_mc and menu_mc to be at the bottom of the screen, use this forumla:


nav_mc._y = Stage.height - nav_mc._height
Basically, take the full height of the window, and subtract the height of nav_mc (or menu_mc). I don't know what you're doing there with your calculations.