— React-Native Programmierer . Patrick Tresp

in 1998, The Raspberry ketone diet drops Raspberry Ketones erection necessary for lovemaking. Research workers screened the African mango fat african mango

While trying to set up a simple Example with the StageVideo in FlashPlayer 10.2 i had lots of trouble setting up the Environment. Neither could i use Flash IDE to export correctly for FP10.2 nor could i use FDT to compile a running version.

I relied on the fact, that Flex Hero automatically includes FP10.2 which turned out to be false. Therefore i downloaded the last update and finally had the playerglobal.swc for FlashPlayer 10.2 available.

After having this working, the Example to check the performance was a piece of cake.

package vid
{
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.StageVideoAvailabilityEvent;
	import flash.events.StageVideoEvent;
	import flash.geom.Rectangle;
	import flash.media.StageVideo;
	import flash.media.StageVideoAvailability;
	import flash.media.Video;
	import flash.net.NetConnection;
	import flash.net.NetStream;
 
	/**
	 * @author patricktresp
	 */
	public class StageVideoTest extends Sprite
	{
		private var _nc : NetConnection;
		private var _ns : NetStream;
		private var _stageVideo : StageVideo;
		private var _video : Video;
 
		public function StageVideoTest()
		{
			var stage : Stage = Main.getInstance().stage;
 
			stage.addEventListener( StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, onStageVideoState );
		}
 
		private function onStageVideoState( event : StageVideoAvailabilityEvent ) : void
		{
			var available : Boolean = (event.availability == StageVideoAvailability.AVAILABLE);
 
			_nc = new NetConnection();
			_nc.connect( null );
			_ns = new NetStream( _nc );
			_ns.bufferTime = 0;
 
			var customClient : Object;
			customClient = new Object;
 
			customClient.onMetaData = onMetaDataHandler;
			_ns.client = customClient;
 
			if ( available )
			{
				addStageVideo();
			}
			else
			{
				addRegularVideo();
			}
 
			_ns.play( "video/hd.f4v" );
		}
 
		private function addRegularVideo() : void
		{
			var stage : Stage = Main.getInstance().stage;
 
			var video : Video = _video = new Video();
 
			video.smoothing = true;
 
			video.attachNetStream( _ns );
			stage.addChildAt( video, 0 );
		}
 
		private function addStageVideo() : void
		{
			var stage : Stage = Main.getInstance().stage;
 
			var v : Vector. = stage.stageVideos;
 
			var sv : StageVideo;
			if ( v.length >= 1 )
			{
				sv = _stageVideo = v[0];
				sv.addEventListener( StageVideoEvent.RENDER_STATE, stageVideoStateChange );
				sv.attachNetStream( _ns );
			}
		}
 
		private function stageVideoStateChange( event : StageVideoEvent ) : void
		{
			resize();
		}
 
		private function resize() : void
		{
			_stageVideo.viewPort = new Rectangle( 0, 0, _stageVideo.videoWidth, _stageVideo.videoHeight );
		}
 
		private function onMetaDataHandler( meta : Object ) : void
		{
			if ( _video )
			{
				_video.width = meta.width;
				_video.height = meta.height;
			}
		}
	}
}

Next Step will be the test within an existing application running in Projector.

For Performance Testing i used a very fast Picture-Changing Movie:

No StageVideo:

Yes StageVideo:

Of Course the video.smoothing has a direct effect on the high CPU-usage, without smoothing:

Still more than 30% saved and another step closer to „green programming“.

Read More

During a Project i needed a method which shuffles a Vector. Since i could not find an implemented shuffle() function i remembered how PHP works with sort-functions and came up with this really simple comparison function:

package de.patricktresp.util
{
	/**
	 * @author patricktresp
	 */
	public class VectorUtil
	{
		public static function shuffleVector( a : Object, b : Object ) : int
		{
			// HIDE FDT WARNINGS
			a;
			b;
 
			return Math.floor( Math.random() * 3 - 1 );
		}
	}
}

So whenever needed i just go:

vector.sort( VectorUtil.shuffleVector );

This works fine for now, but i am very sure there is some more efficient and faster methods.

Suggestions are appreciated.

Read More

Another FFK ( Flash Forum Konferenz ) / beyondtellerrand has passed and left me with new inspirations on how i want to work on and what i want to work on in the future.

Find some interesting Ressources here:

FDT

Molehill

JavaScript

The conference hat obviously more topics than listet before but these are the resources i will need to use in the future.

I am very curious, how molehill will affect the complete Flash importance in the web.

Thanks FFK11!

Read More

When having an external SWF file which needs to be tweened in frames ( e.g. multiple buttons to control the position of swf file ) it always throws performance issues while tweening a frame which is before the current frame ( meaning: reverse tweens ).

After some research i thankfully found following way to force a tween to play forward and loop to reach the desired frame. ( e.g. movie with totalframes 100 is at frame 50, button action: tween to frame 10 )

I was really glad i found this!

TweenLite is downloadable at : http://www.greensock.com/

// header
import com.greensock.TweenLite;
import com.greensock.plugins.*;
 
// function
TweenPlugin.activate( [ FramePlugin ] );
TweenPlugin.activate( [ FrameForwardPlugin ] );
 
var frameForward : uint = 10;
var time: Number = 1;
var _animation : Sprite = getChildByname("animation");
 
TweenLite.to( _animation, time, { frameForward:targetFrame, ease:"easeInOutExpo" } );
Read More

During a Project which had to handle large amounts of BitmapData-Objects i had problems in displaying dynamically created TextFields in the DisplayList. TextFields were not visible on stage, even though the properties were all correct.

Surpisingly i could add other Bitmap-Objects, which are displayed correct, so i used this workaround:

// note: Application.getInstance().getTextFieldTextBounds( textField ) returns the correct amount of space taken from the textField according to http://blog.derraab.com/2010/05/16/aligning-flash-textfield-instances-visually-correct/
 
// create new BitmapData Object using the TextFields bounds and use alpha values
var bm : BitmapData = new BitmapData( Application.getInstance().getTextFieldTextBounds( tf ).width + 20, Application.getInstance().getTextFieldTextBounds( tf ).height + 20, true, 0x00000000 );
// take a SnapShot of the TextField
bm.draw( tf );
// create new Bitmap Object
var bitmap : Bitmap = new Bitmap( bm );
bitmap.x = tf.x;
bitmap.y = tf.y;
// deleting the reference TextField
tf = null;
// adding new Bitmap to a Sprite
s.addChild( bitmap );
Read More

Just a try to use WP-Syntax available at the Plugins page…

ActionScript Code Snippet Test

public static function getSquareButton( width : uint, height : uint, color : uint ) : Sprite
{
	var s : Sprite = new Sprite();
	s.graphics.beginFill( color );
	s.graphics.drawRect( 0, 0, width, height );
	s.graphics.endFill();
	return s;
}
Read More