Featured FLA
» Author: Bugra Ozden
» Title: Skatalog v9 - product catalog
» Description: Create your product catalog easly and publish on your website or Create your image gallery, documents list, portfolio. Fully XML Driven
» More by Bugra Ozden
Featured Site
» Posted in the Flash Kit Links section
» Title: Creative DW Image Show PRO
» Description: Creative DW Image Show PRO is a Dreamweaver extension which enables the user to create multimedia presentations. It combines the features of the popular Creative DW Image Show with the ability to add professional text effects to slides (similar to After Effects). The product is very customizable: the user can choose the duration of the transition effects, the slide motion start and end position, zoom and panning type for both images and texts.
Here we get to our first
branch. Depending on which browser is being used we will retrieve the HREF attribute of
the <A> or <IMG> tag that fired this function in different ways.
In case of Netscape we will use the
TARGET property of the EVENT object to achieve this.
If it is Internet Explorer we will use the EVENT
object too, but due to events 'bubbling up', the syntax is a bit more complex.
We use the split function (from the string object)
plus the Regular Expression to parse the URL and split it every time we find a
non-alphanumeric character. Here's an example:
original URL: www.mysite.com/web/mypage.htm
after splitting the string we get an array that looks
like 0=www 1=mysite 2=com 3=web 4=mypage 5=htm The length for this array is 6 so, we will
use array.length-2 so we get at array[4] which equals 'mypage'. This array element is the
tag that has the same value as the name of one of the Movie Clips inside the Flash Movie
if (arguments[1]=='true'){
if(browser[1]=='NE'&&top.soundtown.document.embeds.misonido.PercentLoaded()!=0){
top.soundtown.document.embeds.misonido.TPlay(soundTag[soundTag.length-2])
}
if (browser[1]=='IE'&&parent.soundtown.document.misonido.PercentLoaded()!=0){
parent.frames['soundtown'].document.misonido.TPlay(soundTag[soundTag.length-2]);
}
}
If the array arguments[1] (the arguments
of the function) equals 'true' it means that the sound should play.
Notice that we are checking the browser and whether
the Flash Movie loaded at least 1%. This is a good place to insert error handling code
since these checks are useless if the invisible frame cannot load its page.
Also notice that to access the Flash Embed you have to use the EMBEDS array
in Netscape or the name of the embed in IE.
PercentLoaded () is a method of the Flash Player that
returns a number indicating the percentage of the movie that has been downloaded so far.
If the movie loaded at least 1% it means that no problems arose while embedding the movie.
This does not mean that the movie is ready to play, so you could
check if the movie is 100% loaded before trying to play it.
TPlay (target as String) is a method of the Flash
Player that lets you play a Movie Clip by passing the method a string with the name of the
target (Movie Clip). See how the method gets its target name from the
URL already parsed.
if (arguments[1]!='true'){ if
(browser[1]=='NE'&& top.soundtown.document.embeds.misonido.PercentLoaded()!=0){
top.soundtown.document.embeds.misonido.TStopPlay(etiqueta[etiqueta.length-2]);
top.soundtown.document.embeds.misonido.TGotoFrame(etiqueta[etiqueta.length-2],1);
}
if
(browser[1]=='IE'&&parent.soundtown.document.misonido.PercentLoaded()!=0){
parent.frames['soundtown'].document.misonido.TStopPlay(etiqueta[etiqueta.length-2]);
parent.frames['soundtown'].document.misonido.TGotoFrame(etiqueta[etiqueta.length-2],1);
} }
return; }
You can call the function using the play
flag as an empty string and be sure that it will be assumed by the function to be a Stop
order.
The TStopPlay(target as
String) method instructs the player to stop playing a Movie Clip, accepting a string as
the Movie Clip name.
After stopping the player we go to Frame #1 using
the TGotoFrame (target as String, frame as Integer) method which
accepts a string as a Movie Clip name and an integer as a frame number. The TGotoFrame method makes sure that every time we play the Movie Clip it
will start from the beginning.
As you can see the code is pretty straightforward. In the next
section we will see how to call this function from HTML using event handlers.
My name is Gonzalo Alustiza and I work as a chief developer at Soundtown
Argentina. Soundtown is a ten year old music production company
specializing in music for advertising and TV which started to develop
sonification solutions for the Internet.