Archive for category: ActionScript

Obfuscate/ hide JavaScript code by including into Flash file

Why / Pro / Con

Of course there will be a lot people who might say that it’s bullshit to include JavaScript into a Flash file (.swf) to obfuscate the JavaScript code – and your right. This is just one thing you can do which has some advantages and also some disadvantages.

In case you want to hide your JavaScript source code not to be seen by other people because it takes you so much time or even money to develop this code – sorry to say, but this will not finally work. There are a lot websites out their which “encrypt” your JavaScript code and make it less readable for humans. But there are as well sites which do the opposit and make it really well readable again. So it will always be possible to have a look at your source code. Also hiding the JavaScript in a flash file will just makes it more difficult, but not impossible, because you could also decompile the flash file.

Added Preloader Examples

Added some example files for the swfJSPreloader: http://blog.sebastian-martens.de/swfJSPreLoader#examples.

cheers,
Sebastian

FOTB 2010 Brighton

Gleich vorweg: Meine erste Flash on the Beach Erfahrung wird definitiv nicht meine letzte bleiben – das ist sicher! John schafft es auf beeindruckende Weise hochkarätige und interessante Speaker zusammenzutragen, die die gesamte Konferenz zu einem inspirierenden Erlebnis für Entwickler und Kreative generell werden lässt. Ganz egal ob man sich dann auch noch mit Flash beschäftigt oder nicht ( auch wenn Flash natürlich ganz klar der Grund und der Fokus der Veranstaltung ist ).

Die FOTB fand im Brighton Dome und näherer Umgebung statt. Es gab bis zu vier parallele Sessions. Für alle die, die keinen Workshop am Sonntag gebucht hatten fing es Montag morgen mit dem Check-In an. Wäre schön gewesen hätte man sein Mobiltelefon auf UK-Zeit umgestellt. Dann hätte man noch ausschlafen können und wäre nicht eine Stunde zu früh.

Nicht nur der Brighton Dome ( ein altes Theater mit entsprechend größer Bühne und klasse Sitzen ) machte gleich zu Beginn Eindruck. Auch das Opening-Video lässt das kreative Herz höher schlagen:

Dynamic Resize Flash Application Container / Flash Stage ( without external JavaScript )

[Update: Add complete Flash Builder project source files. ]
If you have dynamic content within your Flash application or you have several states or “pages” implemented, which all have different content, it might be helpful to resize your flash aplication container within the html- context. For this it’s not enough to resize the application from within the flash application. You also have to resize the surrounding html container. This is the object tag for Mozilla browsers or the embed tag, if the client uses the Internet Explorer.

In each case you have to use the ExternalInterface. You call it from the flash application with parameters for the new height and width value of the flash container. On the other side you have to define an javascript function which do the resize operation with these values.

Here is an AS3 class which already includes the JavaScript part. Soyou don’t have to define an extra JS function. So you just have to import the AS3 class into your project and your ready to resize you application from Flash.

Preload assets with JavaScript, load-complete callback for single assets include SWF/Flash

Currently i need to know within JavaScript when a SWF-file was loaded completly. You could easily handle this with a single ExternalInterface call from within the Flash-application. This is not a very nice solution if this has to be done for each of you flash-applications. This is the neccesary way if you also have to access the flash-application from javascript-side. But in my case i just need to know when the flash is loaded and available in the browser cache.

For this i wrote the swfJSPreLoader. This preloader accepts an array of assets (jpg,gif,png,swf) you would like to preload. Internally it will create an flash-application which does the preloading. You could define several callback handlers. So JavaScript gets to know when all assets are loaded or each single asset is loaded including SWF-files.

Use your Wii-Remote with the FlashPlayer – WiiFlash

You maybe know the Nintendo Wii and its controller the Wiimote. Joa Ebert and Thibault Imbert implement a AS3 package called WiiFlash which allows you to connect the Wiimote ( or Wii Remote Control ) with your Flash/Flex Application.

The Wiimote uses several sensors to detect different motion values. It allows you to read the acceleration value for X-,Y-, Z-axis and Roll, Pitch and Yaw, which is the rotation around the x-,y- and z-axis. So you have a lot more degrees of freedom than with a simple mouse or keyboard. A funny thing you could implement with this for example is WiiSpray, which also uses the WiiFlash Lib.

The WiiFlash package consists of two parts. The first one is the WiiFlash Server. It’s written in C++ / .NET and handles the communication with the Wiimote. The second part is the WiiFlash ActionScript API, which gives you methods and events to get and handle the Wiimote data.

swfInputs: Solving Mozilla + Transparent Mode + Win + Special Chars within inputs

As you probably know the Flash Player uses three different types of modes an Flash movie is embedded in the browser window. Its is set via the wmode parameter in the embed or param tag.

  <param name="wmode" value="transparent" />
  <embed wmode="transparent" ...
</pre/>
With the transparent mode you can influence the relation between the Flash movie an the surrounding HTML. If the set the wmode to window the Flash movie will always lay on top of the rest of the page. This is absolutly helpfull if your application is "standalone", means the only center of user interaction or if you have an full window application ( at least with full screen ).
But often you have other HTML elements around the Flash movie which are at the same level of user interaction and might be as important as the Flash movie ( Best example might by fly-out menus which has to overlay all other content. Or maybe confirm messages which are not realized by the JavaScript confirm-dialog ). If you use <em>wmode</em> window html elements will always behind the Flash movie (setting the html z-index has no effect ), so there is no real interaction between HTML/JavaScript an the Flash movie. For this you need <em>wmode</em> equals <em>transparent</em>.
 <a href="http://blog.sebastian-martens.de/2009/05/swfinputs-solving-mozilla-transparent-mode-win-special-chars-within-inputs/#more-159" class="more-link"> </a>

ActionScript Data Structures

In the good old Java world ( not that i’m that familiar with it ) real data structures are a well non secret. Not only in Java but in all older object oriented progaming languages exists different of Design Patterns for effecient data structures and fast access to data structures for different kind of use cases.

With data structures i don’t mean an normal or byte array which might be the data structures an the flash  world, because you use it without waisting any thought of it ( me included ). in the very most situations were you used the Flash plattform right now this might be ok, because often you don’t have the mass of data. So the performance of the Flash Player is well enough.

But the possiblities of the Flash Plattform are growing ( very fast in the last time :) ) and more and more applications ( also real applications ) are written for the web ( or for both worlds if you use AIR ).

Gallery

IMG_3467 IMG_8547 IMG_6783 img_5549_gs IMG_3950 IMG_3192 IMG_4050 Untitled_Panorama64 img_0089 IMG_3568_grey Untitled_Panorama86 IMG_2405

Latest Comments

Latest Article

Categories

del.icio.us