A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11336 Flash Movies | 2 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Surjit Dhami
» Title: Book
» Description: Book
» More by Surjit Dhami


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

Featured Site

» Posted in the Flash Kit Links section
» Title: All-American Rejects
» Description: Get to know this great band by exploring their "practice room".


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

» 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
» HTML Photo Gallery Tutorial
» Create your first flash site – PART 1
» How to Make a Flash Photo Gallery
» 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 » Actionscripting

Categories How to Create a Flash MX Component
Author: Jonathan Kaye | Website: http://www.amethyst-research.com |

 
Page 19
«prev ... 12 13 14 15 16 17 18 19 20 21 22 23 24 25 next»

Ready or Not, Here we Code

10. The final step is to write the code for the custom UI. In a new layer, enter the following into frame 1:

fscommand("allowscale", "false");
// Set the default property values
xch.tbase = 10;
xch.theight = 10;
xch.tcolor = 0x000000;
xch.applyTint = false;
// Initialize the base and height text fields
bs.text = 10;
ht.text = 10;
compute_fuqu(10, 10);
// Initialize the tint tile and color text fields
tsc = new Color(tintSq);
rc.text = gc.text = bc.text = "0";
setTintSq(0, 0, 0);

// Given a base and height value, compute the fuqu and set the
// fuqu indicator based on the computed value
function compute_fuqu (b, h) {
var fuqu;

if (isNaN(b))
b = 0;
if (isNaN(h))
h = 0;

fuqu = b/h * 4.211;

if (fuqu == 4.211) {
fuquEval.gotoAndStop(1);
} else if (fuqu>= 2.211 && fuqu <= 6.211) {
fuquEval.gotoAndStop(2);
} else {
fuquEval.gotoAndStop(3);
}
// Set the text field that shows the fuqu
fuquTF.text = Math.round(fuqu * 1000) / 1000;
}

// Given a red, green, and blue color value (0-255), create a composite
// color value, set the tint tile, and return the composite color value.
function setTintSq(r, g, b) {
var col = r <<16 | g <<8 | b;
tsc.setRGB(col);
return col;
}

// When the base and height text fields change, recompute the fuqu
// and set the appropriate property in xch
bs.onChanged = function () {
xch.tbase = this.text;
compute_fuqu(ParseFloat(this.text), ParseFloat(xch.theight));
}
ht.onChanged = function () {
xch.theight = this.text;
compute_fuqu(ParseFloat(xch.tbase), ParseFloat(this.text));
}

// Given an integer c, clamp it to values between 0 and 255
function boundColor (c) {
if (isNaN(c))
return 0;
if (c <0) {
c = 0;
} else if (c> 255) {
c = 255;
}
return c;
}

// When the color text fields change, change the tint color
// and set the appropriate property in xch
rc.onChanged = function () {
xch.tcolor = setTintSq(boundColor(this.text), ParseInt(gc.text), ParseInt(bc.text));
}
gc.onChanged = function () {
xch.tcolor = setTintSq(ParseInt(rc.text), boundColor(this.text), ParseInt(bc.text));
}
bc.onChanged = function () {
xch.tcolor = setTintSq(ParseInt(rc.text), ParseInt(bc.text), boundColor(this.text));
}

// The check box (c) calls this function when the user checks or unchecks
// the box. Set the applyTint property of xch appropriately.
function tintApply (c) {
xch.applyTint = c.getValue();
}

«prev ... 12 13 14 15 16 17 18 19 20 21 22 23 24 25 next»

» Level Intermediate

Added: : 2002-04-16
Rating: 8.42 Votes: 54
Hits: 903
» Author
Jonathan Kaye, PhD, is the President and CTO of Amethyst Research LLC, an award-winning interactive design and engineering firm specializing in the creation of online device simulations. He and David Castillo are the authors of "Flash for Interactive Simulation: How to Construct and Use Device Simulations", to be published by Delmar Thomson Learning in November, 2002 (the accompanying web site will be www.FlashSim.com).
» Download
Download the files used in this tutorial.
Download (0 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, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs