PDA

View Full Version : Using HTML scroll for a dynamically sized flash file



makecake
August 22nd, 2006, 03:30 AM
EDIT: Okay, I solved it and it was a lot easier than I thought, anyway, here is a solution if you want to change your swf size dynamically, delete this post if you find it unessecary

first make a swf file containing a movieclip with the instance name "sizeBtn" and add this code to frame1



import flash.external.*;
var command:String;
var targetSize:Number = 700; //the target height

sizeBtn.onRelease = function() {
command = String(ExternalInterface.call("setFlashHeight", "flashid", targetSize));
//make more buttons or functions to change to any other size
}


and publish it to get a html file, you might have to change the publish settings for the HTML a bit if the resizeing behaves strangely.

Then add



<div id="flashid" style="width:550px; height:400px;">

</div>

around the flash <object> tag (change dimensions to suit your needs)

and in the <head> tag add:

<CODE>
<script type="text/javascript">
function setFlashHeight(divid, newH){
document.getElementById(divid).style.height = newH+"px";
}
</script>
</CODE>

and test it, you should now be able to change the height of the flash file from within the swf, animations can probably be added but I haven't gotten around to that yet