Hey Medyman,
I finally got something together after a long and head hurting process... What you supplied really got me going, so thanks again for that! I had to adapt it quite significantly for my needs, it was almost there but not quite.
The main problem was that I couldn't jump back and forth between 100% div layer and a set size div layer. I could only alter the size of it. That was a large chunk of the work taken care of though.
Before this I used a stage listener in flash to update the positions of different elements around the stage
Code:
resizeListener = new Object();
Stage.addListener(resizeListener);
resizeListener.onResize = Delegate.create(this, positionClip);
and when the stage went below a certain size I would call the JavaScript function that would resize the div layer that the flash sat in and thus activated the scroll bars.
However now that the stage was a fixed size and no longer being resized there was no way to tell the javascript to resize the div to 100% when the window was increased beyond the min dimensions again.
To solve that I used a combination of the ExternalInterface.addCallback class in flash and some onresize javascript to send the new dimensions back to flash when the browser got resized, and update the div layer when required.
Flash function:
Code:
...
ExternalInterface.addCallback("onChange", this, onChange);
}
public function onChange(w:Number, h:Number):Void {
stageW = w;
stageH = h;
positionClip();
}
private function positionClip():Void{
if(stageW <= movieWidth){
var result:Object = ExternalInterface.call("setFlashWidth", "flashcontent", movieWidth, "px");
}else
if(stageW >= movieWidth){
var result:Object = ExternalInterface.call("setFlashWidth", "flashcontent", 100, "%");
}
if(stageH <= movieHeight){
var result:Object = ExternalInterface.call("setFlashHeight", "flashcontent", movieHeight, "px");
}else
if(stageH >= movieHeight){
var result:Object = ExternalInterface.call("setFlashHeight", "flashcontent", 100, "%");
}
var i:Number;
for(i in clipArray){
setupPosObj(clipArray[i].myCoor, clipArray[i].myId);
clipArray[i].myId._x = posObj.posX;
clipArray[i].myId._y = posObj.posY;
if(i >= clipArray.length-1){
}
}
javaScript function:
Code:
function setFlashWidth(divid, newW, stateVal){
document.getElementById(divid).style.width = newW+stateVal;
}
function setFlashHeight(divid, newH, stateVal){
document.getElementById(divid).style.height = newH+stateVal;
}
function setFlashSize(divid, newW, newH){
setFlashWidth(divid, newW);
setFlashHeight(divid, newH);
}
function canResizeFlash(){
var ua = navigator.userAgent.toLowerCase();
var opera = ua.indexOf("opera");
if( document.getElementById ){
if(opera == -1) return true;
else if(parseInt(ua.substr(opera+6, 1)) >= 7) return true;
}
return false;
}
//get the correct reference
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName]
}
else {
return document[movieName]
}
}
function alertSize() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
thisMovie('main').onChange(myWidth, myHeight);
}
Theres some more going on besides this, but its all getting very long winded now...
I guess I could just update the size without going back through flash, but I set the movie dimensions through my custom repositioning class, so this way I don't really need to update the javascript again.
I'm sure there's a smoother way, but at least I'm on the right track... I think 
Cheers,
-T.
Check out my results here
The movie is set to kick into scroll bar mode at 955x700
Bookmarks