Resize flash to fit browser, blue screening
Monkey Targets Forums/Flash/Resize flash to fit browser, blue screening
| ||
Anyone had this issue before? I am using JavaScript to resize the flash object, Monkey is detecting this change because some debug data I'm outputting is giving a new device width & height correctly, but the flash element turns completely blue. It works fine before resizing, just once I resize the browser, I'm getting no rendered output at all. I've had a look in mojo.flash.as, seen that on resize it's creating a new bitmapData component: bitmap.bitmapData=new BitmapData( w,h,false,0xff0000ff ); Changing the colour here changes the blue to whatever, so it's getting this far.... Do I need to preform some sort of refresh? |
| ||
I've been able to "fix" this by updating the variable bitmapData. It now reads: bitmap.bitmapData=new BitmapData( w,h,false,0xff0000ff ); bitmapData=bitmap.bitmapData; Can anyone verify if this was a bug/oversight? |
| ||
I'm facing the same issue with v74a. I'm using: stage.align = StageAlign.TOP_LEFT ; stage.scaleMode = StageScaleMode.NO_SCALE ; in a v68 project with success. (The real resolution of the flash canvas fits the html div dynamic size) |
| ||
Just curious, but why not try it out in Experimental v75d? See if perhaps its working there. If not post that here too so that Mark can have a look :) |
| ||
Still the same issue in v75d So here is a test. It works well in v68 (I still work on a project that started with v68 and I hope I didn't modify something in this version). The same code doesn't work with v75d, neither with v69 with the same blue screen. Monkey code Strict Import mojo Import "flashfuncs.as" Extern Function SetScaleMode:Void() Public Class MyApp Extends App Method OnCreate:Int() SetUpdateRate 60 SetScaleMode() return true End Method OnUpdate:Int() return true End Method OnRender:Int() Cls DrawText "Timer: " + Millisecs(), 10, 10 DrawText "Screen: " + DeviceWidth() + "x" + DeviceHeight(), 10, 22 return true End End Function Main:Int() New MyApp return 0 End the flash code file flashfunc.as function SetScaleMode():void { // v75d (since v69) var stage:Stage = BBFlashGame._flashGame._root.stage; // v68 //var stage:Stage = game.stage; stage.align = StageAlign.TOP_LEFT ; stage.scaleMode = StageScaleMode.NO_SCALE ; } and the MonkeyGame.html file with resolution choice <!DOCTYPE html> <html> <head><title>Monkey Game!</title></head> <body> <div id="header_div" style="width:800px;margin-left:auto;margin-right:auto;"> </div> <div style="width:800px;margin-left:auto;margin-right:auto"> <center> <a href="javascript: SetResolution(640,480)"> 640x480 </a>, <a href="javascript: SetResolution(720,540)"> 720x540 </a>, <a href="javascript: SetResolution(800,600)"> 800x600 </a>, <a href="javascript: SetResolution(960,720)"> 960x720 </a>, <a href="javascript: SetResolution(1024,768)"> 1024x768 </a>, <a href="javascript: SetResolution(1280,960)"> 1280x960 </a>, <a href="javascript: SetResolution(1600,1200)"> 1600x1200 </a> </center> </div> <div id="GameDiv" style="width:640px;height:480px;margin-left:auto;margin-right:auto;background-color:orange;"> <embed src="MonkeyGame.swf" type="application/x-shockwave-flash" width="100%" height="100%" wmode="direct"> </embed> </div> <!-- Monkey console for Print --> <textarea id="GameConsole" style="width:640px;height:240px;border:0;padding:0;margin:0" readonly></textarea><br> <script type="text/javascript"> function monkey_print( str ){ var cons=document.getElementById( "GameConsole" ); cons.value+=str+"\n"; cons.scrollTop=cons.scrollHeight-cons.clientHeight; } function SetResolution( x, y ) { d = document.getElementById('GameDiv'); d.style.width=x+"px"; d.style.height=y+"px"; } </script> </body> </html> |