Flash Another Look 21-Nov-15 Computing Engineering and Technology 1 Flash
Flash Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 10 Tricks & Traps AS2 upwards is case sensitive nCounter != ncounter != NCounter Note older code may not work stopAllSounds(); // works stopallsounds(); // does not when using AS2 code Stricter data typing improves run-time performance AS 2 upwards has strict data typing var nCounter:Number = 36 The variable (nCounter) of type (Number) = 36
Flash Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 12 Loop gotoAndPlay() Buttons can be used to break the loop Loop.htm
Flash Another Look 21-Nov-15 Computing Engineering and Technology 13 Key Class Key press can also be used… Key1.htm
Flash Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 20 var speed:Number =3 onEnterFrame = 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 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 Another Look 21-Nov-15 Computing Engineering and Technology 23 References ActionScript 2.0: A Real Programming Language Introducing ActionScript 2 astfts_excerpt/astfts_lesson1.pdf, /actionscript.html astfts_excerpt/astfts_lesson1.pdf /actionscript.html Kirupa ActionScript 2.0 OOP x.htm x.htm