3 flash requests/fixes

Monkey Forums/Monkey Programming/3 flash requests/fixes

slenkar(Posted 2011) [#1]
sorry for posting this in bug reports but i wanted to make sure this was seen.

first request:

mojo.flash.as has 'smoothing' set to true,
So basically flash is doing software anti-aliasing which is extremely slow.

to fix:
1.go into mojo.flash.as and search for .draw
2.on each instance set the last function argument to false

the graphics draw a lot faster, a lot of monkey developers might appreciate this.


second request


Flash has strange input behaviour, when you hold down a key you get repeated keydown events that accumulate in a queue.
if you change mojo's as3 input commands to reflect this you get more responsive input

1.comment out these lines in endupate
internal function EndUpdate():void{
//for( var i:int=0;i<512;++i ){

//keyStates[i]=0;
// }
charGet=0;
charPut=0;
}
2.alter onkeydown so that keystates simply equals 1 when pressed
internal function OnKeyDown( key:int ):void{
if( (keyStates[key]==0)){//&0x100)==0 ){
keyStates[key]|=1;//0x100;
//++keyStates[key];
}
}
3.alter keyup so that keystate simply equals zero when released

internal function OnKeyUp( key:int ):void{
keyStates[key]=0;
}
4. keyboard input is much more responsive when a game slows down

third request

please make it so that assets are not embedded when compilation is done in debug mode, embedding is slow when you have a lot of images and there is no point in embedding them unless you are releasing the game.


thanks!


marksibly(Posted 2011) [#2]
Hi,

> mojo.flash.as has 'smoothing' set to true,

I can unset this, but I'm pretty sure it was originally set at the request of users - possibly back in devteam days though.

Perhaps the best idea would be to make it a 'config' style option so it can be set per project?

> 1.comment out these lines in endupate

Please post some code to show what problem or bug this fixes. To me, it looks like it's doing exactly what the original does, except it's throwing away keyhit state after a keyup, which could mean you miss a keyhit if a down/up pair occurs between updates.

Also, the code you've suggested be 'remmed out' in EndUpdate isn't the current mojo code - perhaps your version diverged somewhere along the way?


AdamRedwoods(Posted 2011) [#3]
Adobe Flash vector is anti-aliased by default. This is best.

Now, if the IMAGES are aliased, yes, this will slow things down. Smoothing images is NOT turned on by default. There is an option under Flash for smoothing images, but done image-by-image:
Bitmap.smoothing = true //under AS3.

Most Flash games are coded by the developer to allow the _user_ to choose the "speed" mode which toggles between anti-aliasing or not. Usually under an option menu.


slenkar(Posted 2011) [#4]
ok ill take another look at the input stuff later, its not such a big deal when anti-aliasing is turned off anyway.

Anti-aliasing should be a choice I suppose (for developer and user)
Some people making casual games will probably want it, and those wanting raw speed will not.

I dont think anyone will object to embedding images only on release

-adamredwoods if you look into mojo.flash.as you will see that images are being antialiased on bitmapdata,draw


marksibly(Posted 2011) [#5]
Hi,

Moving this as it's not strictly speaking a bug.

I'll keep an eye on the topic though...


slenkar(Posted 2011) [#6]
Mark , could you post the code to load an image when it is external?
(in mojo.flash.as)
I could eventually work it out myself but it would take me a while.

EDIT-
public function LoadSurface( path:String ):gxtkSurface{
 		if (debug==true)
         {   var loader:Loader = new Loader();
            loader.load(new URLRequest("data/"+path));
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
       return null;
		}
	else
	{	var bitmap:Bitmap=loadBitmap( path );
		if( bitmap ) return new gxtkSurface( bitmap );
		return null;
	}
	return null;
	}


ok i got this far but i need to delay the program while the image loads


slenkar(Posted 2011) [#7]
Mark , could you post the code to load an image when it is external?
(in mojo.flash.as)
I could eventually work it out myself but it would take me a while.

EDIT-
public function LoadSurface( path:String ):gxtkSurface{
 		if (debug==true)
         {   var loader:Loader = new Loader();
            loader.load(new URLRequest("data/"+path));
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
       return null;
		}
	else
	{	var bitmap:Bitmap=loadBitmap( path );
		if( bitmap ) return new gxtkSurface( bitmap );
		return null;
	}
	return null;
	}

private function onComplete(e:Event):void
        {
            new gxtkSurface(e.target.loader.content.bitmapData);
        }


ok i got this far but i need to delay the program while the image loads