Question pertains to right naviagation of this page
http://dev.fusionapps.com/wboe/dsp_home_page.cfmWill open multiple questions if this is not an easy fix.
Wondering if there is more dynamic way of using cold fusion and flash to handle the output height and width of the swf movie. Right now if I publish the movie clip at 200 x 450 pixels, there leaves room for two more buttons to be entered in the swf movie size. But the right nav is always changing so if I enter a third it won't display becuase the movie size is too small in the html embed and param tags. I could easily export the movie again with a taller height like 600 pixels but that changes the layout of the webpage because content in a lower <TR> gets pushed way down in the site and leaves an empty space. I need to do something like this but can't figure it out.
Webpage calls SWF but waits to get width and height somehow before displaying ---> SWF calls CFM file to get cats and subcats from database then CFM outputs cats and subcats to flash ---> Flash builds the cats, subcats, and adds spacer when necessary ---> Then I need a way to add the total height and width up in flash ---> Output these two values to the embed and param tags of the webpage that's calling the SWF. Is this possible?
Right now I have the calling cfm:
<CFIF findNoCase("msie",HTTP_USE
R_AGENT)>
<!--- Initialize swf file which calls /wboe/flash/right_nav/dsp_
menu_categ
ories.cfm to get category header,
subcategory names and urls from database then builds buttons dynamically with a default height of 21 pixels
and expands to compensate for multi-line buttons.
There is a 3 pixel spacer between each category and subcategory.
There is an insert of 50 pixels between each category in flash.
If the total height of category headers, subcategories buttons and spacers is over 450 pixels,
buttons outside of the 450 pixels will not display, need to increase the two height settings below to fix. --->
<OBJECT
CODEBASE="
http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
WIDTH="200"
HEIGHT="450"
ID="wboe_right_nav" ALIGN="">
<PARAM NAME=movie VALUE="/wboe/flash/right_n
av/wboe_ri
ght_nav.sw
f">
<PARAM NAME=quality VALUE=best>
<PARAM NAME=menu VALUE=false>
<PARAM NAME=wmode VALUE=transparent>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="/wboe/flash/right_nav
/wboe_righ
t_nav.swf"
menu=false
quality=best
wmode=transparent
bgcolor=#FFFFFF
WIDTH="200"
HEIGHT="450"
NAME="wboe_right_nav"
ALIGN=""
TYPE="application/x-shockw
ave-flash"
PLUGINSPAGE="
http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
<CFELSE>
Non-Flash Content
</CFIF>
Here's the dsp_menu_categories.cfm that gathers the data from the database
<cfcontent type="text/plain">
<cfsetting enablecfoutputonly="yes">
<!--- query to get the main categories --->
<cfquery datasource="flashmenu" name="get_cats" dbtype="odbc">
SELECT catid,category
FROM cats
</cfquery>
<!--- initialize the category list --->
<cfset cats="">
<!--- initialize the counter --->
<cfset count=0>
<!--- loop through the categories query --->
<cfloop query="get_cats">
<!--- append the category to the category list --->
<cfset cats=ListAppend(cats,categ
ory,"|")>
<!--- now query to get the sub categories and url links --->
<cfquery datasource="flashmenu" name="get_subcats" dbtype="odbc">
SELECT subcategory,url
FROM subcats
WHERE catid=#catid#
</cfquery>
<!--- initialize the subcats list --->
<cfset subcats="">
<!--- initialize the urls list --->
<cfset urls="">
<!--- create another loop for the subcategories --->
<cfloop query="get_subcats">
<cfset subcats=ListAppend(subcats
,subcatego
ry,"|")>
<cfset urls=ListAppend(urls,url,"
|")>
</cfloop>
<!--- output the subcats and the urls --->
<cfoutput>
&subcats#count#=#subcats#&
urls#count
#=#urls#
</cfoutput>
<cfset count=count+1>
</cfloop>
<!--- output the cats --->
<cfoutput>
&cats=#cats#&loaded=1&
</cfoutput>
And here's the flash actionscript that builds the menu:
data_var = new LoadVars();
data_var.path = this;
data_var.onLoad = function(ok)
{
if(ok){
this.path.menuGeneration(t
his);
} else {
trace("CFM PAGE MISSING");
}
};
function menuGeneration()
{
var startY = 1, depth = 0;
var temp = data_var.cats.split("|");
// Set Font Styles
// textFont is embedded Futura Md BT from Flash
// Verdana is rendered as html font
// new TextFormat(font, size, color, bold, italic, underline, url, target, align, leftMargin, rightMargin, indent, leading)
var style1_fmt = new TextFormat("textFont", 14, 0x000000, false, false, false, "", "", "center");
var style2_fmt = new TextFormat("Verdana", 12, 0x000000, true, false, false, "", "", "left", "3", "5", "");
for(var i = 0; i < temp.length; i++){
// Set a spacer in between categories
if(depth > 0){
startY += 50;
trace("ADDED 50 SPACER")
}
// Create empty movieclip and set the depth
var mc = this.createEmptyMovieClip(
"main" + depth, depth);
depth++;
// Set Stroke Color and Opacity
mc.lineStyle(1, 0x912211, 100);
// Set Fill Color and Opacity
mc.beginFill(0xEDD593, 100);
// Draw a box
mc.lineTo(198, 0); mc.lineTo(198, 20); mc.lineTo(0, 20); mc.lineTo(0, 0);
// Stop fill
mc.endFill();
// Create text box
mc.createTextField("text_t
xt", 1, 0, 0, 198, 20); //name, depth, x, y, width, height
// Text box parameters
mc.text_txt.selectable = false;
mc.text_txt.embedFonts = true;
mc.text_txt.text = temp[i];
mc.text_txt.setTextFormat(
style1_fmt
);
mc._x = 1; mc._y = startY;
startY += mc._height + 1;
var subText = data_var["subcats" + i].split("|");
var subLink = data_var["urls" + i].split("|");
for(var j = 0; j < subText.length; j++){
var sc = this.createEmptyMovieClip(
"sub" + depth, depth);
depth++;
sc.createTextField("text_t
xt", 3, 0, 1, 198, 20); //name, depth, x, y, width, height
sc.text_txt.multiline = true;
sc.text_txt.wordWrap = true;
sc.text_txt.autoSize = "left";
sc.text_txt.selectable = false;
sc.text_txt.embedFonts = false;
sc.text_txt.text = subText[j];
sc.text_txt.setTextFormat(
style2_fmt
);
var hgt = sc.text_txt._height + 2 > 20 ? sc.text_txt._height + 2 : 20;
sc.lineStyle(1, 0x912211, 100);
sc.lineTo(198, 0); sc.lineTo(198, hgt); sc.lineTo(0, hgt); sc.lineTo(0, 0);
sc._x = 1; sc._y = startY;
startY += sc._height + 1;
var lc = sc.createEmptyMovieClip("c
lick_btn",
2);
lc._x = lc._y = 1;
lc.lineStyle(0, 0, 0);
lc.beginFill(0xEDD593, 100);
lc.lineTo(197, 0); lc.lineTo(197, hgt - 1); lc.lineTo(0, hgt - 1); lc.lineTo(0, 0);
lc.endFill(); lc._alpha = 0;
lc.link = subLink[j];
lc.onRollOver = function() { this._alpha = 100; };
lc.onRollOut = lc.onDragOut = function() { this._alpha = 0; };
lc.onPress = lc.onDragOver = function() { this._alpha = 100; };
lc.onRelease = function() { this.getURL(this.link); };
}
}
delete data_var;
}
data_var.load("/wboe/flash
/right_nav
/dsp_menu_
categories
.cfm");