Flash ActionScript – getURL in AS3

Flash ActionScript

After a long time I am writing something…during my project I found out something interesting in Flash and JavaScript function. This will be useful for people with basic knowledge in Actionscript. So let’s discuss it here.

First we will discuss about the difference between AS2 and AS3 script on Flash button. Previously in AS2 it’s very easy to write script on Flash button.

AS2 script on Flash button:

on(release){

//Write your action

trace(“Button has been pressed”);

}

And function should be like this (this should be placed on the keyframe of timeline (make actionscript layer) :

function myFunction(){

//Write your action

trace(“Hello”); //write trace option

}

Above example was quiet easy with AS2, now let’s see same example with AS3:

Important point to remember is that in AS3 you can’t write script on button. Just write it on keyframe in timeline (make actionscript layer). And give instance name to your button e.g. HelloButton. Now write the button script on keyframe of timeline:

AS3 script for Flash button:

HelloButton.addEventListener(MouseEvent.CLICK, myFunction);

Here, we have use button name i.e. HelloButton. And a function i.e. myFunction

In AS3 function is written as:

function myFunction (event:MouseEvent):void{

                trace(“Hello”);

}

In above function, remember to add “event:MouseEvent” and “:void” as compare to AS2, which tells that on which mouse event this function should execute.

Now let’s discuss about simple script of “getURL”. Previously it was easy to open a webpage on click of a Flash button. You just need to put this script on Flash button. See example:

on(release){

                //getURL(“http://www.google.com”, _blank);

                }

After clicking this button it will open an http://www.google.com link in new window.

But now if you just put this script on Flash button and publish HTML, you will find that it’s not working….don’t worry this is just a simple glitch within your HTML…….try to find out this param tag…in HTML:

<param name=”allowScriptAccess” value=”always”/>

Make sure that….value=”always”….if you want to run getURL script on Flash button….Now your Flash button works perfectly in HTML.

Now learn something interesting, capture Flash button event in Javascript of HTML page. Check AS2 and AS3 versions:

AS2 version:

On Flash button write this script:

on(release){

               getURL(“javascript:myfunction()”);           

}

In above script, “myFunction()” is a javascript function which is present in HTML.

In HTML, where you are going to run this Flash button, just write javascript function “myFunction()” in <body> section. Check this:

JavaScript Function in HTML

<script language=”JavaScript”>

function myfunction(){

alert(“Hello World”);       

}

In the object tag for the SWF file in the containing HTML page, set the following parameter:

<param name=”allowScriptAccess” value=”always” />

Now check above scenario in Actionscript 3:

AS3 version:

import flash.external.ExternalInterface;

Instead of “getURL”, in AS3 we should use “ExternalInterface” classes. For more details check link: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html

import flash.events.Event;

HelloButton.addEventListener(MouseEvent.CLICK, myFlashFunction);

Above code is for Flash button with instance name: “HelloButton”, and when someone press this button it execute “myFlashFunction”(JavaScript function).

 

function myFlashFunction (e:Event):void{

     ExternalInterface.call(“myfunction”, HelloButton.name);

};

myFlashFunction is a Flash function which runs javascript function(i.e. myfunction) in HTML file.

 

And in HTML, place this javascript function:

<script language=”JavaScript”>

function myfunction(){

alert(“Hello World”);       

}

In the object tag for the SWF file in the containing HTML page, set the following parameter:

<param name=”allowScriptAccess” value=”always” />

 

Now run HTML file in Internet Explorer (browser). And when you press Flash button in SWF file in the containing HTML page, javascript code catch the Flash button event. This way you can catch any Flash event in javascript and use for many purposes. Hope this will be helpful for those who want to understand basic event catching with JavaScript from Flash.

Apple’s green signal to Flash CS5 iPhone Application

Good news for Flash lovers, Apple released a new version of its SDK license agreement recently. In this new release Apple amended the infamous section 3.1.1 that bans the use of 3rd party languages to develop iPhone applications, the new section now allow developers to use the API in the manner prescribed by Apple and prohibits the use of private API. So now onwards iPhone apps  made using iPhone Packager in Flash CS5 will not be banned for the mere fact that they were not originally written using Objective-C. After this news Adobe announced that they are resuming development work on this feature for future releases of Adobe Flash CS5®.

Reason for this change of mind of Apple is not clear. May be due to competition from Android, or fear for some legal hassles etc. Whatever may be the reason, its certainly a great news for Flash developers because now they can easily develop applications for iPhone and the iPad by using ActionScript 3.0 and Adobe Flash CS5®.

Reference: http://blogs.adobe.com/conversations/2010/09/great-news-for-developers.html, Republic of Code

Audio Knowledge

audioFriends, I found some of my interesting old notes on ‘audio’. I feel it is worth to share with you.

  1. Audio role in Multimedia
  • Attracts your attention/shocks/excites
  • Change moods
  • Feeling as you are in dream
  • Give pleasure
  • Inform
  • Inform with style and impact

2. Audio is applied to

  • Narration
  • Dialogs, Conversation
  • Background music
  • Music mixed with narration
  • Transition effects in audio
  • Noise
  • Real/Informative sounds

3. Selection of audio for multimedia

  • Topic of multimedia presentation
  • Sound related to information
  • Objective of presentation
  • Desire effect for presentation
  • Target Audience
4. Factors which affects quality of recording
  • Breathing
  • Air conditioner noise
  • Movement
  • Suitability of recording settings
  • Input volume level
  • Consistency of settings
  • Quality of source audio
  • Quality and connectivity of cables

5. Sound Card

  • 8bit, 16bit, 32bit

6. Layout of sound card

  • Microphone connector
  • Line in Jack
  • Microphone in Jack
  • Speaker out/Line out Jack
  • Joystick/MIDI connector
  • IDE connector

1.       Audio File formats (mentioning only few)

  • AU files: (.au) are the most commonly used format format for cross-platform applications (the µ-law format, is also called AU from the file extension used for these files)
  • AIFF files: Audio Interchange file format files (.aiff, .aif, and .aifc) are widely used on Macintosh and silicon graphics computers
  • WAV files: WAV files(.wav) are used with Microsoft Windows applications
  • MP3 files: By eliminating portions of the audio file that are essentially inaudible, mp3 files are compressed roughly one-tenth of audio formats such as WAV(uncompressed)etc.
  • WMA files: Window Media Audio
  • RA files: Real audio file format designed for streaming audio over the internet
  • RIFF files: Resource Interchange File Format. Developed by Micorsoft
  • SND/Sound files : This file format was developed by Apple and is l, imited to a sampling rate of 8bits
  • MID/MIDI/MFF files: Musical Instrument Digital Interface, stores MIDI data
  • VOC files: Voice, developed for Sound Blaster card by Creative Technology. Supports sampling rates of 8 and 16 bits, with or without compression

8. Qualities of Sound

  • Nature of sound: Oscillatory movement of air particles forming directional longitudinal waves
  • Waveform: Describes measurement of speed of the sound
  • Amplitude: Relative loudness of the sound
  • Volume: The amplitude determines the sounds volume, measured in decibels. Human hearing range from 1 to 120 decibels

9. Basic Qualities of Sound

  • Valley and Crest: The lowest part of a waveform is reffered as valley and the peak point as the crest
  • Frequency: No of crests that occur in one second is the frequency also called as Pitch
  • Mono: Sound using only one channel
  • Stereo: Sound using multimedia channels. Digital stereo uses two channels namely Left and Right

10. Analog and Digital Audio

  • Analog: Continuous stream of the waveforms
  • Digital: Finite numerical combinations representing the waveform
  • Requirement of conversion: To handle the sound using computer(digital device) it needs to be converted into digital form
  • Conversion Methods: Use of ADC (Analog signals => electrical impulses => ADC => Digital Sound)

11. Benifts of Digital Sound

  • 100% reproduction
  • Easily Editable
  • Long Lasting
  • Timely Retrieval on Demand
  • Availability of Reliable Storage Media

12. Sampling/Resolution

  • Sampling: The process of digitization of the analog sound
  • Sampling rate: Number of samples per second
  • Typical rate can range from 5000 to 100000 samples per second
  • The number of bots used to store each sample is known as the resolution of the sound
audio_table

MIDI: Musical Instruments Digital Interface

  • MIDI is a simple digital protocol
  • By connecting a computer to a keyboard through a MIDI connection, music can be recorded
  • Many programs are supporting MIDI for communicating with synthesizers. MIDI files are widely used for exchanging computer music

References for content and images: Internet and multimedia books

Aptech aquires MAAC

Aptech Ltd. on 28 Jan 2010,  announced its acquisition of Maya Academy of Advanced Cinematics (MAAC). The acquisition is through the takeover of 100% equity shares of Maya Entertainment Ltd.(MEL) , the parent company of MAAC.  MAAC, one of the largest players in the Animation & Multimedia education industry, is a premium brand with over 70 centres spread throughout India. Aptech has his brand, Arena Animation, the leader in the field of Animation and Multimedia education in Asia. The deal is valued at Rs. 76 cr . In my view a great move by Mr. Ninad Karpe the CEO & MD of Aptech. This move again reposition Arena Multimedia as number 1 in Multimedia, Animation and also strenthen itself in 3D/VFX education market also.

For more details check link: http://www.animationxpress.com/index.php?file=story&id=25611

Avatar: New era of virtual movie making

avatar_img_01‘Avatar’….yes a movie which is creating history right now. After ‘Lord of the Rings triology’ this is another movie which is responsible for changing the film and entertainment industries perspective, I also want to add game industry into it because game industry will get a huge benefit from technologies which ‘Avatar’ develops.
I watched this movie on first day first show and that too was morning 7.30 AM show. I want to tell that not only technology wise but philosophically also this movie is great. It shows the bonding between nature and its creatures in an emotional way, we don’t skip this aspect of the movie.

My friends were asking me to write something on ‘Avatar’ and its technology, but I need time to search and read articles before writing something. I find out some nice information, so let’s share.

James Cameron’s ‘Avatar’ is continuing its domination on box office worldwide in its fourth week, film domestic total till now is $429 million. And overseas, ‘Avatar’ grossing are $902 million (Reference: http://www.animationmagazine.net/article/11030).  WOW !!! don’t you want to say. It will soon toppling down Cameron’s last box office hit ‘Titanic’, which has done business of $ 1.8 billion.

Before starting to talk on technologies I just want to describe some definitions:
CG = Computer Graphics
CGI = Computer Generated Imagery

CGI is a specific application of CG in that it refers to the use of computer graphics to create synthetic imagery. However, the two terms are sometimes used inter-changeably in the visual effects industry.
In a broad sense, computer-generated is an adjective that describes any element created by a computer– as opposed to shot live on a set or location.

Stereoscopic 3D (S3D): Stereoscopy, or stereoscopic imagery, uses the characteristics of human binocular vision to create the illusion of avatar_img_02depth, making objects appear to be in front of or behind the cinema screen. The technique relies on presenting the right and left eyes with two slightly different images which the brain automatically blends into a single view. Subtle right-left dissimilarities in the images create the perception of depth and can be manipulated to creative advantage. Therein lies the art of stereoscopic filmmaking. (Reference: www.autodesk.com)

Now comes to technologies used in ‘Avatar’. Lightstorm Entertainment, production company of James Cameron’s, developed a new motion picture production process to create the groundbreaking sci-fi epic ‘Avatar’. They combine live action 3D and computer generated, photo-real visual effects to develop a great sci-fi story.

Ubisoft, a game company, also launch ‘Avatar’ in a third-person adventure game form. It can be played with stereoscopic 3D (S3D) display.
Lightstorm Entertainment, pioneered a new method for making visual effects movie with advanced virtual cinematography techniques. They use ‘Autodesk®MotionBuilder®’ and ‘Autodesk®Maya®’ software for this film. Production team captures actor’s performances and apply them directly to computer graphics (CG) characters, while viewing the results in real-time. This movie sets a new standards in stereoscopic 3D(S3D) productions. Lightstorm refined the performance capture techniques and apply them to high resolution Maya character models to create realistic, believable, animation.

This movie starts new era of virtual moviemaking, which gives full freedom to director’s creativity. Hoping that in near future Directors try to replace actors with this CG characters….which doesn’t have any date problem and exorbitant fees….:)

 
References: http://usa.autodesk.com/adsk/servlet/item?id=14270942&siteID=123112; http://www.animationmagazine.net/article/11030; google search

Swift 3D plug-in: Convert 3D animation to vector

Friends, thanks for your encouraging comments on my articles. Some ask that why I am not updating my blog regularly, one reason for not writing on regular basis is due to less time availability. Due to recession and heavy work pressure, I do not have much time to write research articles. I don’t want to write those news items which you easily gets on every website, I try to write article after doing complete research on the subject.
Wait for my next article which will most probably on interactive 3D model. I am doing research on the same, and already made a really cool interactive 3D model. So just wait for my new article.
Here we talk about software (plug-ins) which helps to convert 3D animation into vector animation (i.e. Flash SWF). Isn’t it sound interesting?
Electricrain, a company made a software plug-ins for LightWave 3D and 3ds Max  i.e.  ‘Swift 3D LW’ ; and  ‘Swift 3D MAX’. With the help of these plug-ins, users of 3ds Max and LightWave 3D can render their 3D scenes in high-quality, low bandwidth vector or raster Flash animations.

swift3d_img_02

These plug-in are powered by industry-leading RAViX 4 vector rendering technology. Swift 3D plug-ins gives superior Flash integration and additional export formats including Adobe Illustrator, EPS, SVG and Toon Boom’s PNT format.
It is simple to use plug-in. You just need to install it (according to the installation manual), and it appears into your software as shown in below Figure.

swift3d_img_01

You just select your output format i.e. swf, eps, ai etc. in the SWIFT 3D window and render it, you will get the desire output in vector format. WOW…quite easy and very useful. I have use lots of SWF files in my project and it is quite easy to show a 3D model/animation made in LightWave3D in Flash with full control. You just need to import the SWF (3D animation) file into your Flash project and your 3D animation would work perfectly in Flash without consuming much memory. Same thing happens with 3ds Max.

Just download a trial and enjoy it!

For more information, please check the link: erain dot com/products/plug-ins/

Reference/Image (First Image) courtesy: erain dot com

Special Fx: VisionLab Studio

Filmmaking is not an easy task; it requires creativity and technical expertise. When you want to use some special effects in your movie/film or project etc. it requires lots of knowledge of difficult software’s (which are costly too), as well as their complicated interfaces.

If you had face the same situations anytime during your projects than here is a solution for you and that is ‘VisionLab Studio’ from Fxhome. You can get more details about this and other product on http://fxhome.com/. VisionLab Studio is all-in-one toolkit for visual effects, compositing and color grading. Other products by FXhome is ‘EffectsLab Pro’, which is used for advanced visual effects for low-budget filmmaking; ‘PhotoKey’, which is helpful to discover the creative possibilities of green screen photography; ‘VideoWrap’, which convert your video for iPods, mobile phones, YouTubes and more.

In this article we discussed about VisionLab Studio, with very easy to use interface and preconfigured effects library, VisionLab Studio makes endless possibility for your creativity.

Keying: VisionLab Studio has a wide variety of versatile keying abilities. As you were aware that keying is a technical feature, which is used to developed special effects scene from greenscreen video to photos and CGI.

Particles: You can create many effects such as weather, smoke, and fire and fantasy visuals with very sophisticated particle system.

Grade: Color grading for your movie or project is available in an easy way. You can use filters like bleach bypass, day for night and multicolorize.

Muzzles: Muzzles flashes are basically used for historical, modern and futuristic weapons. These flashes you can rotate in 3D with full control on each feature

 

Software screenshot
Software screenshot

 

Lightning: You can create good effects of lightning as well as effects for magical and sci-fi effects.

Optics: This feature helps to generate lens flares and lightning, which will be enhance the overall look of the scene.

Mask: With the freehand shapes you can mask any complicated areas for effects. This makes tidying composites garbage matting, simulating depth, layer interaction and area-specific grading quick and easy.

Neon Light: This feature gives you the power to develop Star Wars sword effects. With freehand tool you can directly draw shapes on the video that is very easy to work.

Compatible:  VisionLab Studio is compatible with other software’s such as Apple Final Cut Pro and Adobe Premiere.

Lots of helpful tutorial videos are available on the Fxhome website, which helps you to learn this product.