flash another look 21-nov-15 computing engineering and technology [email protected] 1...
TRANSCRIPT
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
2
Ch.Ch.Ch…Changes David Bowie
• “Only the wisest and stupidest of men never change.” – Confucius
• “Change is inevitable - except from a vending machine.” – Robert C. Gallagher
• “We cannot become what we need to be by remaining what we are.” – Max Depree
• “To change and to change for the better are two different things.” – German proverb
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
3
Why Scripting ?
• Import and export information, create forms, network communications programs
• Personalise the user’s experience
• Control movie clips and their properties more tightly
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
4
Why Scripting ?
• Build dynamic projects that vary according to information like weather data or the day of the week
• Dynamically control sound volume and stereo panning
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
5
ActionScript (AS 1)
ActionScript 1 (Flash 1-5)• Good for simple interactivity• Basic “Glue” coding• Plenty of code available but – code rough• Limited capabilities led to some bad coding• Non-Standard language – loosely related to JavaScript• Was very slow• Even sloppy code runs
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
6
ActionScript (AS 2)
ActionScript 2 (Flash 2004 – 8)• A proper OO language• Good for more complex coding• Deeper control of Flash capabilities• More flexible programming environment• Better de-bugging capabilities• Cleaner coding – more readable (transferable .dir)• Stricter syntax and error checking
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
7
ActionScript (AS 3)
ActionScript 3 (CS3 – CS4)• Full OO language• Everything is now an object which can or has to be
called up dynamically.• Objects are embedded into objects as children ie:- the
screen is an object which has active sprites within it as children.
• A child inherits attributes from the parent as well as controlling their own attributes.
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
8
Adaptability
• You can still program using ActionScript 1.0 in Flash MX 2004 and in Flash 8
• Performance of AS1 is good in MX 2004 and Flash 8
• ActionScript 2 code strongly resembles Java
• ActionScript 2 knowledge can easily be re-used in the industrial strength, cross-platform world of Java
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
9
Adaptability
• The code in Flash now runs a minimum of 5 times faster than AS 1
• This opens Flash up to more potential uses especially the world of on-line and mobile games and communication using complex processing
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
10
Tricks & Traps• AS2 upwards is case sensitive
nCounter != ncounter != NCounter
• Note older code may not workstopAllSounds(); // worksstopallsounds(); // does not when using AS2 code
• Stricter data typing improves run-time performance
• AS 2 upwards has strict data typingvar nCounter:Number = 36The variable (nCounter) of type (Number) = 36
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
11
Loop gotoAndPlay()• Loops can be used to create a
menu section where the film is waiting for a key or mouse event to happen
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
12
Loop gotoAndPlay()• Buttons can be used to break the
loop
• Loop.htm
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
13
Key Class• Key press can also
be used…
• Key1.htm
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
14
Key Class• The script needs to account for the frame the video head is moving through.
onEnterFrame = function() {
if(Key.isDown(Key.UP)){
gotoAndPlay(1);
}
}
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
15
Screen Plotting• The screen is plotted from the top left hand corner of the user screen.
._x is the horizontal plotting position
._y is the vertical plotting position
• Objects can be placed on the desktop (off main screen) and called into position at will.
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
16
Screen Plotting• The number relates to the
position on screen relative to screen size
• Hence – ._x =150 would be half way across a 300 pixel screen
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
17
Screen Plotting• If you wanted an object to move onto and across the
screen you would start it off in a -._x position then give it a variable speed.
Round._x = -50
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
18
Screen Plotting• Scroll.htm
• The scripting would go so…
var speed:Number = 10
onEnterFrame = function() {
if(Key.isDown(Key.RIGHT)) {
round._x += speed;
}
}
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
19
Screen Plotting• The project is built up in small sections each
overlaying the next to create the effect needed.
• Key X-Y.htm
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
20
var speed:Number =3onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)){round._x += speed;round._y += speed;
} else if (Key.isDown(Key.LEFT)){round._x -= speed;round._y -= speed;
} else if (Key.isDown(Key.DOWN)){round._y += speed;round._x -= speed;
} else if (Key.isDown(Key.UP)){round._y -= speed;round._x += speed;
} else if(Key.isDown(65)) {round._x -= speed;
} else if (Key.isDown(68)) {round._x += speed;
}else if (Key.isDown(87)) {round._y -= speed;
}else if (Key.isDown(83)) {round._y += speed;
}}
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
21
Interaction• It is then possible to begin to create imagery to
fit into the scene.
Full.htm• You begin to develop more involved interaction.
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
22
Conclusion• Giving the user the ability to control items creates interactivity.
• Control of items is built up by creating small functions.
• Functions can work together to create sophisticated imagery and action.
Flash
Anoth
er
Look
Apr 20, 2023 Computing Engineering and Technology [email protected]
23
References
• ActionScript 2.0: A Real Programming Languagehttp://www.peachpit.com/articles/article.asp?p=102204
• Introducing ActionScript 2http://www.macromedia.com/devnet/mx/flash/articles/astfts_excerpt/astfts_lesson1.pdf,
http://www.macromedia.com/devnet/flash/actionscript/actionscript.html
• Kirupa ActionScript 2.0 OOPhttp://www.kirupa.com/developer/oop2/AS2OOPindex.htm