negush blog

Flash, ActionScript and stuff…

Finally… I’m in the mood of writing again… I’m sorry to say that it’s a long time since my last article, but hopefully that is going to change.

A lot has happened in the Flash world these past few month and I’m sure you’re up to date with the news so there’s no need for me to list them.

Anyway, if you noticed, during the summer JumpeyeComponents launched a new web application called PhotoSnack. It allows you to create very nice online Flash photo albums. Well, JumpeyeComponents has just launched an updated version of PhotoSnack for testing, which can be found at http://dev.photosnack.net. It has many more features than the initial version and a total of 13 albums to choose from. Here is a short video to get you started: http://dev.photosnack.net/help/tutorials/getting-started/.

Besides PhotoSnack, JumpeyeComponents also launched the SnackTools, which is a suite of web applications containing both PhotoSnack and BannerSnack. All of the web applications are only for testing purposes and JumpeyeComponents is happy to receive your feedback on the applications. There’s also a full-discount coupon (TEST) used to unlock the premium features.

One important thing to note is that the accounts you create in the test applications will be deleted without any notice once the testing is over and the applications are released in their final version. Just keep this in mind while you are playing around with the apps.

This being said, I hope you’ll all have fun with the SnackTools. I’m looking forward to see some interesting examples. If you have any comments on the applications (ideas, bug reports or any other comment) feel free to leave a note here or write to JumpeyeComponents through the feedback application they have on each of the SnackTools web apps.

July-2-09

FlashEff2 officially launched

posted by admin

Today JumpeyeComponents has officially launched the next version of the popular Flash animation tool – FlashEff. Now it has a redesigned workflow that makes life even easier and comes with a solution to lower the file size of your Flash clips: the FlashEff2 component has a lower size than the predecessor and it comes with another set of components – FlashEff2 Light.

The FlashEff2 Light pack contains separate animation components, each one specialized to do one of the main component’s jobs: show/hide animations for symbols, show/hide animations for texts, applying filters, creating buttons and executing commands. So you can use only that one feature you really need for your project without having to import all the FlashEff2 features into your Flash clip. This way you can lower the file size of the final animation even more.

Here are some other features for FlashEff2:

  • a large number presets that you can choose from (3000+ presets)
  • the possibility to tweak those presets or to make your own settings
  • create and save your own custom effects which you can reuse any time you want
  • a completely new button mode

Here you can find more information on the component’s features and watch some nice video tutorials that will help you get started with FlashEff2. There’s even a nice video on the home page based on the comments users left on this JumpeyeComponents blog post.

I’m testing the Red5 server to see how to use it for audio and video streaming but right after testing the connection to the server, I get the following error message in my Output Panel (though the connection to the server has been established correctly):

Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection 
was unable to invoke callback onBWDone. error=ReferenceError: Error #1069: Property 
onBWDone not found on flash.net.NetConnection and there is no default value.

After digging around it seems that I didn’t specify the client for the NetConnection object:

netConnection.client = this;

After setting the client property, all was well. So don’t do the same mistake as I did.

There are situations when you need to create a web application that is part Flash, part HTML, like some handy widget that must reside in an HTML page and that would also have to communicate with it. The next example presents a simple color setting widget made with Flash, which communicates with the web page it is integrated in. Basically the Flash widget contains three slides to set the RGB color value and the composed color is displayed in the HTML page, in a text input control. The user also has the possibility to enter a hexadecimal value of a color in that text input which will set the sliders in the Flash widget to the corresponding values. Flash – HTML communication (actually ActionScript – JavaScript communication) is possible by using the ExternalInterface class within the flash.external package.

The ExternalInterface class was created to replace the older fscommand() function and can be used to call JavaScript functions from ActionScript or call ActionScript functions from JavaScript. It is also able to transmit a return value from the function being called to the code (ActionScript or JavaScript) calling the external function. It is much more flexible than fscommand() since it allows calling any JavaScript function defined in the HTML file with any number of arguments (of various data types), while fscommand() allowed calling a limited number of functions with a single String as argument. Also allows receiving a return value from the JavaScript function call to ActionScript and vice versa.

Calling a JavaScript function from ActionScript is quite easy. All you have to do is call the static call function of the ExternalInterface class:

ExternalInterface.call("myJSFunction");

You can even specify function parameters and receive the return value, like this:

import flash.external.ExternalInterface;
var value:String = ExternalInterface call("myJSFunction", param1, param2, param3);

Of course this means that in the HTML file containing your Flash clip there has to be a JavaScript function defined with the name of “myJSFunction”. In the above example, we presume that the type of the return value of the JavaScript function is a String, but the ExternalInterface class allows receiving other types of values too.

Calling an ActionScript, from within your HTML document using JavaScript is equally easy. All you have to do is get a reference to the Flash object embedded into the HTML document and then call the ActionScript function directly on this object. Of course, this requires that the ActionScript function is defined as a callback function for the JavaScript code, in the main timeline of the Flash clip:

ActionScript code:

ExternalInterface.addCallBack("myASFunction", someASFunction);

JavaScript code:

var flashMovie = window.document.MyFlashWidget;
flashMovie.myASFunction(value);

In this case, the name and id attributes of the Flash object must be set to “MyFlashWidget”. Another requirement for the HTML document is to set the allowScriptAccess attribute of the Flash object to “always”.

“myASFunction” is the function name that the external JavaScript code must call, but the actual name of the ActionScript function is “someASFunction”. This way, external JavaScript code can only have access to the ActionScript code that the developer allows to. Also, in this case, if the ActionScript code must change and the “someASFunction” function is removed, there could be another function passed to the addCallBack method. Thus, it is ensured that “myASFunction” always gets called by JavaScript and that Javascript can actually be oblivious to the changes of the ActionScript code.

One more thing worth mentioning is that it is a good practice to check if the JavaScript code is available for calling, before actually making any calls to it. This way possible errors or malfunctions are avoided in the application:

if (ExternalInterface.available) {
	try {
		ExternalInterface.addCallback("myASFunction ", someASFunction);			}
	catch(e:Error) {
		// Callback function could not be added for various reson.
		// You could treat this situation here.
	}
}

You can download the full example from here. I hope it will help out some of you.

Update: For Internet Explorer you should make sure that you specify your embedded Flash object the id attribute, as mentioned in this post: ExternalInterface.call not working with IE.

December-28-08

Personal website or blog: that is the question

posted by admin

I’ve been pondering from quite some time whether there’s any reason for me to have a personal website and the blog or simply the blog. Last year, when I’ve started this blog, I had in mind to create my own personal website (in Flash of course) that I would fill with all sorts of stuff. A year has passed and… nothing… I didn’t really have the time to think at my site, let alone to start working on it. Naturally, I started wondering if I would really need a site since the blog could cover all the topics I want. I could have a page with all my personal projects, a page for Flash/Flex/Air resources, maybe even a photo gallery and all this in the blog itself. So I could just concentrate on shaping and customizing my blog instead of creating a personal site from scratch. I mean, the blog is already there. It’s all set up. All I have to do is come up with some nice design (that I could even find ready-made on the Internet) and simply add all the information I want to share… easy as that. Plus, the entire back-end is already in place.

Right now, I think today is much easier to set up a personal website based on a blog, than to create your own site from scratch. Of course you could just purchase a website template, but that would need more tinkering since it usually doesn’t fit one’s needs. So, finally, I took the decision to drop the idea of a personal website and instead just have some sort of welcome page that would redirect to the blog itself and do my magic on the blog. Hopefully I’ll have some spare time to create that welcome page in the next year :)).

December-27-08

Merry Christmas to all of you

posted by admin

Here is a Christmas greeting e-card made by me with bannersnack, a new banner maker web application from JumpeyeComponents.

Happy Holidays folks !

December-17-08

Create Flash banners without Flash

posted by admin

Today JumpeyeComponents launched a new web application called BannerSnack that lets anybody easily create Flash banners and publish them. The product is still in its beta stage but most of the features are already implemented and working. All you have to do to create a Flash banner is to create your account on BannerSnack, access the application from the website and start using it.

By using a free account, you can create, save and publish your banners without problems but there are a few limitations in comparison with the premium account:

Free account Premium account
you can only choose from a limited number of banner sizes you can create custom size banners
you do not have access to all the setup parameters of the animations and filters you can fully customize the animations and filters
you have a limit of 25 MB of storage space for your images you have a 250 MB storage space for your images

All these limitations are gone if you purchase a premium account, which costs from $9 per month up to $149 per year.

The application itself is easy to use and has a fairly intuitive interface. The banners are based on a slide like structure with different types of transitions between them. You can use text and images for your banners on which you can apply different show/hide animations and filters. These filters and animations are based on the FlashEff engine, so you can use many of the eye-catching animations possible only with FlashEff.

Once you finished your banner, you can save it in your account and then publish it to the web. You can even set the banner to be public, which means other users will be able to access and edit it. Of course, their changes will not reflect in your banner, they will be saved separately.
But enough talking… I mean writing… For more information you can simply access www.bannersnack.com to check it out and to start using the banner maker application. There’s even have a short video presentation of the features of BannerSnack and you can also read a blog about a interesting stuff on marketing and banners (I’ve already subscribed to this blog… you should too).

November-28-08

How to preload AS3 clips

posted by admin

There are a lot of cases when your Flash animation is quite large in terms of file size. It contains images, perhaps some smaller .flv movies or a few “heavy” components.

In this case, if you publish your project somewhere on the web, you might have to wait a little, some times a little more, until the clip loads and starts playing. In this case it is very common (and quite frankly, necessary) to display something while your clip loads so the viewer knows there’s something going to happen and wait until your clip is completely loaded. In AS2 this wasn’t so hard. All you had to do was to move your animation to start from the third frame (but not necessarily), deactivate the “Export on first frame” setting from your symbols and components in the Library, place them on the second frame of your movie so they would load their assets (not necessary for all of them) by the time they would be instantiated, change the frame onto which classes were loaded from frame 1 to frame 2 and finally write some code on the first frame that would set an onEnterFrame event handler to display a preloader clip according to the size of your clip loaded so far. Lee Brimelow has made a nice video tutorial on how to preload flash clips, posted here: http://www.gotoandlearn.com/play?id=18. Again, this part isn’t necessary if you don’t want to display the amount of downloaded data and you only have a nice animation instead.

For ActionScript 3.0, the same thing is possible, only with the code changed to the AS3 syntax. You can download the example file from the link at the end of the post. However, this not always works. I’ve tried this with several components and looks like the method described earlier does not fully work. This is the case when using JumpeyeComponents’ TxEff or FlashEff. Even if you un-check the “Export in first frame” option from the Linkage Properties dialog box, there still is a considerable amount of data loading on the first frame. Don’t know why, yet… probably it has to do something with the embedded text (remember that TxEff and FlashEff need embedded characters for text effects). If this is the case, then you’ll probably have to wait a while until even your preloader shows up.

A workaround I’ve been using for this problem is to create the animation clip normally, without considering any preloading and then create a second clip I would use to load the first clip. This second loader clip would have all the preloading capabilities implemented into it. So, now I’m preloading an external .swf file. There’s also an item in JumpeyeComponent’s Knowledge base that addresses this issue: http://www.jumpeyecomponents.com/knowledgebase/TxEff-AS3.0/Preload-TxEff-animations~439/.

However, this arises another problem: in case of timeline animations, if that animation is in the external .swf file that you’re preloading, it so happens that the animation would start before the preloader is gone (while the preloading action is still going on). In this case, there’s a simple solution: move the entire timeline animation so it starts on the second frame and on the first frame place a stop() function. This way, your swf will not start the animation. Finally, after all the external .swf is loaded, just access the content in your loader object and instruct it to start playing from the second frame by using a gotoAndPlay(2) or gotoAndStop(2), if that’s the case.

You can check out these examples I’ve made.

November-18-08

News from Adobe – The Flash Platform

posted by admin

Adobe just announced their Flash Platform, which now includes both Flash Player and Adobe AIR, the tools for developing content for the players, the Flex framework (not the builder… that’s the tool), all sorts of servers to be used with Flash and third party stuff… From now on, this all this will be referred to as Flash Platform. Also, the diagram representing the entire Flash Platform shows the design tools (After Effects, Illustrator, Fireworks and Photoshop) that can communicate with he development tools of the platform, through the FXG format. The development tools of the platform are of course Adobe Flash and Flex Builder and a new tool for those who tend to be more design centric than code centric in their work – Flash Catalyst (formerly known as Thermo).

Catalyst will be announced by Adobe at the Max conference (which is going on these days). Also, the newest version of AIR is out – AIR 1.5 – which has been much improved from the previous version (better performance, Flash Player 10 and Webkit support) – go on and download it, if you didn’t already. Gumbo (the new Flex Builder 4) will also be available for preview and presented at Max. It seems that the new Flex Builder will have lots of improvements that will be followed (hopefully) by a new lightweight and scalable framework.

October-4-08

Flash font size limit

posted by admin

It seems that Flash has a limit for the font size. Normally, it displays the text with a font size of up to 127 px. So I tested it to see if there’s any workaround for this limitation and the easiest thing to do is set the size of the font to less than 128 px and then scale the text field until the size of the font suites your needs. This is what Colin Moock recommends in his article.

However, it seems that there is an exception to this font size rule: if you add a text field to the Stage using the Text tool in design time and not using code in runtime, it lets you use font sizes greater than 127 px (I’ve tested it with a font size of 300 px) ONLY AND ONLY if you DO NOT USE the “Render text as HTML” option. I’ve tested it with all three types of text field: dynamic, static and input; with and without embedded fonts; with single line and multiline; with and without border; using device fonts, bitmap fonts and anti-aliased fonts. And it worked with several types of fonts.

So, if you would like to use font sizes greater than 127 px and your text is static, just place that text in design time and don’t use it as HTML text. You can even update the contents by code and the font size will be kept, even when using the htmlText property to set the new text. But it seems that as soon as you use the “Render text as HTML” option on the text field, the font size limit kicks in. When you use code to create and set the text field, that rule always applies.

The new Flash Text Engine from Flash Player 10 no longer has this limit when using the new TextElement class, but the limit is still applied to all traditional text, according the Colin Moock’s article.