A couple of weeks ago I finished reading the book "Developing Flex 4 Components" by Mike Jones. The reviews on Amazon.com were very promising and during my Flex 3 developing I always wished such a book. For this reason my expectations were very high.
I wasn't disappointed. The book is a perfect continuation of the Flex 4 beginner book "Flex 4 - Training from the source". Even it repeats some content like Data Binding and basics of developing custom compontents, it was enjoyable to read. Mike Jones has a really nice writing style for explaining the core concepts of the Flex 4 component and skinning architecture very easily. These chapters are really one of the best availabe informations to these kind of topics. Completely new for me was the chapter about "working with Metadata". I learnt some deep concepts behind the Meta-tag usage of the Flex Framework. The same is valid for the "Distribution" part of the book. The development worklflow with Flash Library Project, Component Integraton in Flash Builder 4, and the Documentation part are very helpful for my future projects.
Read more...
A couple of weeks ago I finished reading the book "Developing Flex 4 Components" by Mike Jones. The reviews on Amazon.com were very promising and during my Flex 3 developing I always wished such a book. For this reason my expectations were very high.
I wasn't disappointed. The book is a perfect continuation of the Flex 4 beginner book "Flex 4 - Training from the source". Even it repeats some content like Data Binding and basics of developing custom compontents, it was enjoyable to read. Mike Jones has a really nice writing style for explaining the core concepts of the Flex 4 component and skinning architecture very easily. These chapters are really one of the best availabe informations to these kind of topics. Completely new for me was the chapter about "working with Metadata". I learnt some deep concepts behind the Meta-tag usage of the Flex Framework. The same is valid for the "Distribution" part of the book. The development worklflow with Flash Library Project, Component Integraton in Flash Builder 4, and the Documentation part are very helpful for my future projects.
I can highly recommend this book for experienced beginner and intermediate Flex Developers. For really advanced Flex developers I missed some more deeper information. Here is my wishlist for a second edition (maybe it comes some time?!):
Data Binding: This topic is mentioned but I wish more deeper information like the presentation "Diving in the Flex Data Binding Waters" by Michael Labriola and the compound data object approach by Olikhver Sergey
Component Skinning architecture for multi-screen objects: If you have a very complex application or you have to create various skins for various devices, you can run very fast in an architecture nightmare. See the article Advanced Flex 4 Skinning Techniques by Pavel Jacko
Differences between mobile component and desktop component development
For some certain cases the hack with the mx_internal namespace makes still sense. A short segment or a mini chapter about the use of this approach would be nice.
Test Driven Development with Flex Unit: I don't know if Flex Unit really belongs to this kind of book, but if you are creating a component library, then you should use Flex Unit. Just for ensure the quality of your compontes for upcoming versions. Especially, writing and managing Flex Unit code for visual components is always tricky. Some advices for this topic would be so nice.
That is all what I can say. Mike Jones wrote a really good book about Flex 4 component development. It is a must-buy for every Flex Developer.
I was very pleased that YouTube released a ActionScript 3 API for their Chromeless Player. I looked at some availabe code snippets on different blogs and unfortunateley, I had to realize that the API is not really object-oriented and a little bit annoying to work with (because of the missing code completion).
My current project - an independent Web Video Player - is still using the old workaround YouTube API Tubeloc and I have to change this. That is the reason why I created a Flex Component for the new YouTube AS3 API. If you would like to use my code for your Flex or Air projects, please feel free to use it and if you will find some bugs, please leave a comment!
Now I will start with some explanations of my code. I create 4 classes, which manage the whole YouTube Chromeless API. The class YouTubeAs3 contains all the most important functions and is based on the Flex Framework(!). The classes AirYouTube and FlexYouTube extends the YouTubeAs3 class. Both classes are Flex Framework based classes. I had to divide the YouTubeAs3 class into these 2 classes, because the Adobe Air environment don't support the command Security.allowDomain() and it is cleaner to use this command for a web-based projects. So therefore please use the FlexYouTube component for web-based projects and the AirYouTube component for your Air projects. The fourth class FlashYouTube is an only Flash plattform based class, that should be very handy to use for non-Flex projects. Read more...
I was very pleased that YouTube released a ActionScript 3 API for their Chromeless Player. I looked at some availabe code snippets on different blogs and unfortunateley, I had to realize that the API is not really object-oriented and a little bit annoying to work with (because of the missing code completion).
My current project - an independent Web Video Player - is still using the old workaround YouTube API Tubeloc and I have to change this. That is the reason why I created a Flex Component for the new YouTube AS3 API. If you would like to use my code for your Flex or Air projects, please feel free to use it and if you will find some bugs, please leave a comment!
Now I will start with some explanations of my code. I create 4 classes, which manage the whole YouTube Chromeless API. The class YouTubeAs3 contains all the most important functions and is based on the Flex Framework(!). The classes AirYouTube and FlexYouTube extends the YouTubeAs3 class. Both classes are Flex Framework based classes. I had to divide the YouTubeAs3 class into these 2 classes, because the Adobe Air environment don't support the command Security.allowDomain() and it is cleaner to use this command for a web-based projects. So therefore please use the FlexYouTube component for web-based projects and the AirYouTube component for your Air projects. The fourth class FlashYouTube is an only Flash plattform based class, that should be very handy to use for non-Flex projects.
The other classes just simplify the coder's life. So I created some static classes for the various video quality parameters (YouTubeVideoQuality Class), the various PlayerStates (YouTubePlayingState), the YouTube errors (YouTubeError) and of course the available YouTube events (YouTubeEvent).
I wrote an example application for you, which should be very easy to understand. In this very small Flex application you can stop, play and pause the YouTube videos:
//----------------------------------
// YouTube Player Control
//----------------------------------
private function handlePlay(event:MouseEvent):void
{
youTubePlayer.playVideo();
this.addEventListener(Event.ENTER_FRAME,handlePlayingTime);
}
private function handlePause(event:MouseEvent):void
{
youTubePlayer.pauseVideo();
this.removeEventListener(Event.ENTER_FRAME,handlePlayingTime);
}
private function handleStop(event:MouseEvent):void
{
youTubePlayer.stopVideo();
this.removeEventListener(Event.ENTER_FRAME,handlePlayingTime);
}
// frame-based Intervall for showing loading and playing process
private function handlePlayingTime(e:Event):void
{
labelTime.text = youTubePlayer.getCurrentTime() + " / " + youTubePlayer.getDuration();
progresPlayingVideo.minimum = 0;
progresPlayingVideo.maximum = youTubePlayer.getDuration();
progresPlayingVideo.setProgress(youTubePlayer.getCurrentTime(),youTubePlayer.getDuration());
progressLoadVideo.minimum = 0;
progressLoadVideo.maximum = youTubePlayer.getVideoBytesTotal();
progressLoadVideo.setProgress(youTubePlayer.getVideoBytesLoaded(), youTubePlayer.getVideoBytesTotal());
}
Some behaviours of this Flex-based YouTube component is adjusted for the Flex Framework. If you would like to change the size of the YouTube Player, you can use the witdh and height properties of the component. Furthermore there exists some other properties:
[Bindable] public var volume:int; // Value between 0 and 100
[Bindable] public var playerState:Number; // Read-only!!!!
[Bindable] public var playbackQuality:String; // Use the static variables of the YouTubeVideoQuality class
Handling and managing of the YouTubeEvents are the last thing I would like to explain. I support the same 4 events, which the YouTube API supports. The only difference is that I wrapped the data of the events in a special YouTube Event for an simpler event handling and code completion.
[Event(name="youtubeStatus", type="de.derhess.video.youtube.YouTubeEvent")]
[Event(name="youtubePlayerLoaded", type="de.derhess.video.youtube.YouTubeEvent")]
[Event(name="youtubeError", type="de.derhess.video.youtube.YouTubeEvent")]
[Event(name="youtubeVideoQuality", type="de.derhess.video.youtube.YouTubeEvent")]
So here I is my code of my app. I think it is very self-explanatory...
/* Here should be some code but wordpress always crashed
because of parsing problems... Please download the code
and look at line number 23-112 in the src folder the file
flex_youTube.mxml */
The rest of the functions contains exactly the same functionality as the YouTube API. If something ambiguous, please look at the YouTube API documentation or leave a comment. THX!
Download the Flex YouTube components and source code
//