PDA

View Full Version : fabridge and Flex Component Kit, autoscale flash object?



thor918
July 31st, 2007, 09:40 AM
Hi,
I have a html page where I have put my flex object, with height="400" width="400" as you see below...


<script type="text/javascript" charset="utf-8">
document.write('<object id="flexApp" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,5,0,0" height="400" width="400">');
document.write('<param name="flashvars" value="bridgeName=example"/>');
document.write('<param name="src" value="app.swf"/>');
document.write('<embed name="flexApp" pluginspage="http://www.macromedia.com/go/getflashplayer" src="app.swf" height="400" width="400" flashvars="bridgeName=example"/>');
document.write('</object>');
</script>

in this flex object I have put an flash component (using the Flex Component Kit). All this works good. but what I do want to know is how can one autoscal the flash object so that it does not go over height="400" width="400" ? I don't want any scrollbars!

http://labs.adobe.com/wiki/index.php/Flex_Component_Kit_for_Flash_CS3
http://labs.adobe.com/wiki/index.php/Flex_Framework:FABridge

the best would be if the flash object would automaticly scale down to fit the max size of the flex object witch is the parent container in my setup.
Thanks for your comments! :ear:

thor918
August 1st, 2007, 06:31 AM
okey.
I found this code:
http://www.kirupa.com/forum/showthread.php?t=270139&highlight=scale
I changed it to be scale using width instead and pasted the code into the flash movieclip. however it would be better if both height and width would be taken into consideration to constrain the maxsize of the movieclip.
the code works good if I put it into a frame of the movieclip.
however when if I use the same in a package class that extents the same movieclip, it will not work. (means that it does not do anything)


package {
import flash.display.MovieClip;
import mx.flash.UIMovieClip;

public class showbuilder extends UIMovieClip{
var myMaxWidth:int = 0;
var myMaxHeight:int = 0;
public function showbuilder():void{
}

public function setMaxSize(myMaxWidth:int, myMaxHeight:int):void{
this.myMaxWidth = myMaxWidth;
this.myMaxHeight = myMaxHeight;

var widthPercent:Number = this.width / 100;//this.myMaxWidth;
var newheight:Number = this.height / widthPercent;
this.height = newheight;
this.width = 100;//this.myMaxWidth;
}

}
}





var widthPercent:Number = this.width / 100;//this.myMaxWidth;
var newheight:Number = this.height / widthPercent;
this.height = newheight;
this.width = 100;//this.myMaxWidth;

thor918
August 2nd, 2007, 04:26 AM
hmm okey. it seems that the problem is flex.
flex will not autoscale no mater what i do!
how do I get flex to autoscale?
I started something basic now until I get autoscaling going.
The picture inside this flex application will not scale!


<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" viewSourceURL="srcview/index.html">
<mx:Image id="bilde" width="198" height="300" scaleContent="true">
<mx:source>n875895386_336706_7360.jpg</mx:source>
</mx:Image>
</mx:Application>

thor918
August 3rd, 2007, 10:49 AM
Okey, sample code that will autoscale image in flex.



<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" viewSourceURL="srcview/index.html">
<mx:Image id="bilde" width="100%" height="100%" scaleContent="true">
<mx:source>n875895386_336706_7360.jpg</mx:source>
</mx:Image>
</mx:Application>


however setting width and height in procentage to the usercontroll will screw things up...

thor918
August 4th, 2007, 09:58 AM
solved, using a actiongscript to resize the movieclip!