Commit 87a44763 authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.

Initial commit

parents
9780596006457
\ No newline at end of file
The code in Hack #10 uses AS2.0 classes and is not therefore compatible with Flash MX.
A Flash MX 2004 version of the code is available in the Flash MX 2004 specific download for this hack.
\ No newline at end of file
The code in Hack #10 uses AS2.0 classes and is not therefore compatible with Flash MX.
A Flash MX 2004 version of the code is available in the Flash MX 2004 specific download for this hack.
Some of the examples in hack#14 use AS2.0 classes and are therefore not compatible with Flash MX. If you have Flash MX 2004 available, the following additional files are included in the Flash MX 2004 download:
CreateButton.as
createButtonTest.fla
The files pageTurn01.fla to pageTurn04.fla show the page turning effect being developed, and introduce the concepts behind the code in the same order they are discussed in the book.
The final effect is included as pageTurn.fla.
Hack #46 is not compatible with Flash MX becuase it uses Flash MX 2004 specific CSS support. If you have Flash MX 2004, you will see the following additional files in the Flash MX 2004 download:
HTML01.fla
HTML02.fla
myExternalCSS.css
walk.jpg
Hack #46 is not compatible with Flash MX because of differences in the TextFormat class. If you have Flash MX 2004, you will see the following additional file in the Flash MX 2004 download:
helptext.fla
\ No newline at end of file
hack #76 is specific to ActionScript 2.0 and so is not relevant to Flash MX.
\ No newline at end of file
hack77_clone02.swf Movie Report
--------------------------------
Frame # Frame Bytes Total Bytes Scene
------- ----------- ----------- ----------------
1 565 565 Scene 1 (AS 2.0 Classes Export Frame)
Scene Shape Bytes Text Bytes ActionScript Bytes
------------------------- ----------- ---------- ------------------
Scene 1 0 0 547
ActionScript Bytes Location
------------------ --------
547 Scene 1:Layer 1:1
This diff is collapsed.
// This ActionScript 2.0 code must go in an external Transform.as file
class Transform {
// NEG_TRANS inverts the color values.
// NEUTRAL_TRANS resets the color values.
// BLACK_TRANS sets the color values to black.
// WHITE_TRANS sets the color values to white.
// RATE sets the rate the effects will run at in ms.
private static var NEG_TRANS:Object = {ra:-100, rb:255, ga:-100, gb:255, ba:-100, bb:255, aa:100, ab:0};
private static var NEUTRAL_TRANS:Object = {ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0};
private static var BLACK_TRANS:Object = {ra:100, rb:-255, ga:100, gb:-255, ba:100, bb:-255, aa:100, ab:0};
private static var WHITE_TRANS:Object = {ra:100, rb:255, ga:100, gb:255, ba:100, bb:255, aa:100, ab:0};
private static var RATE:Number = 50;
private var interval:Number;
private var startTime:Number;
private var colorObj:Color;
// Constructor accepts target clip to which to apply transforms
public function Transform(targetClip:MovieClip) {
colorObj = new Color(targetClip);
}
// Inverts the color values
public function invert():Void {
colorObj.setTransform(NEG_TRANS);
}
// Resets the color to the default values set in the authoring tool
public function reset():Void {
colorObj.setTransform(NEUTRAL_TRANS);
}
// Performs a fade to black over specified duration in ms
public function fadeToBlack(duration:Number):Void {
applyTransform(BLACK_TRANS, duration);
}
// Performs a fade to white over specified duration in ms
public function fadeToWhite(duration:Number):Void {
applyTransform(WHITE_TRANS, duration);
}
// Function to initiate a fade and set up an interval to
// complete it over time.
private function applyTransform(transObject:Object, duration:Number):Void {
var getTrans:Object = colorObj.getTransform();
var diffTrans:Object = new Object();
startTime = getTimer();
for (var i in transObject) {
diffTrans[i] = (transObject[i]-getTrans[i])/(duration/RATE);
}
// Use the form of setInterval( ) that invokes a method of an object,
// so that instance properties are in scope (the object is this).
// First parameter is the object (this) on which to invoke the
// method specified by the second parameter (in this case
// "transition", which must be passed as a string).
// Third parameter is interval duration in ms.
// Fourth and fifth parameters get passed to transition( )
interval = setInterval(this, "transition", RATE, transObject, diffTrans, duration);
}
// This method applies each step of the color transformation.
private function transition(transObject:Object, diffTrans:Object, duration:Number):Void {
var getTrans:Object = colorObj.getTransform();
for (var i in diffTrans) {
getTrans[i] += diffTrans[i];
}
colorObj.setTransform(getTrans);
if (getTimer()-startTime>duration) {
// Complete the final step in the transition
colorObj.setTransform(transObject);
// Clear the interval to stop the effect
clearInterval(interval);
}
// Force the screen to refresh between frames
updateAfterEvent();
}
public function die():Void {
// Perform any cleanup code here
}
}
// This ActionScript 2.0 code must go in an external CreateButton.as file
class CreateButton {
// Variable target is the timeline that the
// CreateButton instance will create buttons on.
private var target:MovieClip;
// Constructor.
public function CreateButton(targetTimeline:MovieClip) {
target = targetTimeline;
}
// Define createBtn( ) method
// Arguments:
// buttonName - The instance name of the created button.
// dynaLabel - The label text of the created button.
// depth - The depth of the created button.
// x, y - The position of the created button.
// Returns:
// A button movie clip with instance name buttonName.
public function createBtn(buttonName:String, dynaLabel:String, depth:Number, x:Number, y:Number):MovieClip {
// Initialize.
var clip:MovieClip;
var clipMask:MovieClip;
var txt_fmt:TextFormat;
var clipText:TextField;
// Create button clip.
clip = target.createEmptyMovieClip(buttonName, depth);
drawPip(clip);
clip._x = x;
clip._y = y;
// Create button hit area.
clipMask = clip.createEmptyMovieClip("mask", 0);
clipMask._visible = false;
drawPip(clipMask);
clip.hitArea = clipMask;
// Create TextFormat object for applying formatting.
txt_fmt = new TextFormat();
txt_fmt.font = "_sans";
txt_fmt.size = 12;
// Create textField (i.e., the button label).
clip.createTextField(buttonName+"_txt", 1, 10, -10, 100, 20);
clipText = clip[buttonName+"_txt"];
clipText.text = dynaLabel;
clipText.setTextFormat(txt_fmt);
return clip;
}
private function drawPip(clip):Void {
clip.lineStyle(15, 0x0, 100);
clip.moveTo(0, 0);
clip.lineTo(0.2, 0);
}
}
The files pageTurn01.fla to pageTurn04.fla show the page turning effect being developed, and introduce the concepts behind the code in the same order they are discussed in the book.
The final effect is included as pageTurn.fla.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment