Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author: Nick Kouvaris
»  Title: Znax
»  Description: Znax is a board game. Click 4 tiles of the same color and form squares as big as you can. You will erase all the tiles inside the square and collect points. Get maximum score if you make a square with game edges.
»  More by: Nick Kouvaris


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

Featured Site

»  Author Agence WOP Digital Agency
»  Title: Electricdrum
»  Description: French WOP Agency, 3D websites, Flash (Papervision, Away 3D), event or institutional projects. The agency operates on all digital projects: consulting, design, graphic design, development, online communication. The WOP agency follows you on the implementation of original, creative and optimized digital projects.


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

» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» How To Make A Fathers Day Slideshow
» How To Make A Transparent Background of Your Flash File
» Create Flash Banner With Text Disco Light Effect Today we will introduce you a Text Disco Light eff
» Unknown Tag: Title10
Random Tutorial | Add Site


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.45 Votes: 55
Hits: 908
» 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