A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11337 Flash Movies | 1 New Flash Movies Added
What's New | Top 100

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


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 5828 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

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.


Random Links | Add your own Flash Related Links
Flash Tutorials 1280 Tutorials 7 New Tutorials Added!
What's New | Top100

» Make a Flash Slide Show Screen Saver
» Simple flash making tutorial for thanksgiving
» Create flash banner for website
» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» Unknown Tag: Title10
Random Tutorial | Add Site

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Interactivity

Categories How to affect Flash with Javascript.
Author: Chris Petersen | Website: http://www.petersenonline.net |

 
Page 1
1

Javascript Flash interaction tutorial.

There is a lot of documentation on how to call Javascript from within Flash. I am fairly new to Flash, having only used it over the last couple of months and I had no trouble figuring out how to make calls to Javascript from with in my Flash movie. I did however encounter a lot of trouble finding information on how to do the opposite. That is how to affect change in a Flash movie from Javascript.

 This is surprisingly easy considering the difficulty I had tracking down how to do it. The first step is to create a very simple flash movie. All you need to add to this movie is one text string. Type whatever you like into it. Next move to the "Text Options" window and switch the first drop down to "dynamic text". In the text box underneath the word "Variable" you can type what ever variable name you want. For the purpose of this tutorial we'll use the name "jtext". Next save and publish the movie.

 Once you publish the movie, copy the html page that flash built for you. We can use this as our template. Edit the copy you just made. First think of a name for your movie. This is how the JavaScript willl reference your movie. I chose the name "FlashTest". In the OBJECT tag that Flash created for you, place the parameter ID='FlashText' and in the EMBED tag, place the parameters NAME='FlashTest' and swLiveConnect=true. It is very important that the ID tag and the NAME tag have matching names. The swLiveConnect parameter is only nessacary for Netscape. Now your Flash tags should look something like this:

<OBJECT ID='FlashTest'
 classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
 WIDTH=550
 HEIGHT=400>
 <PARAM NAME=movie VALUE="text.swf">
 <PARAM NAME=quality VALUE=high>
 <PARAM NAME=bgcolor VALUE=#FFFFFF>
 <EMBED NAME='FlashTest'
 src="text.swf"
 quality=high
 bgcolor=#FFFFFF
 WIDTH=55
 HEIGHT=40
 TYPE="application/x-shockwave-flash"
 PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
swLiveconnect=true>
 </EMBED>
</OBJECT>

 Now it is time to add some interactivity. Place the following JavaScript function in your tag.

<SCRIPT LANGUAGE='JavaScript'>
<!--
 function interactive(text) {
 window.document.FlashTest.SetVariable("jtext", text);
 }
-->
</SCRIPT>
That script will change the text in your flash movie to whatever it is passed. It is important to note that the text in bold has to match the name of your variable in your flash movie. The final step in this process is to give the user a means of changing the text. Add a text input anywhere on the page, and add an onChange event. It should look like the following:
<INPUT TYPE=text NAME=flash_text onChange='interactive(this.value)'>
That says that whenever the user changes the text that is in the text box, update your flash movie accordingly. Voila, you have made your flash movie change from Javascript.

--By Chris Petersen

1

» Level Intermediate

Added: : 2001-02-19
Rating: 8.35 Votes: 233
Hits: 3523
» Author
I am a web developer specializing in Enterprise Development using Java. I work as a contractor and have only recently started dabbling in with Flash.
» Download
Download the files used in this tutorial.
Download (3 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs