This is an introduction to scripting in Flash CS 5 using ActionScript 3.0. I briefly go over the interface and then show how to use Code Snippets in Flash as well as some found code to start making things happen based on KeyboardEvents. We also start to learn about Arrays and how to write to get code to cycle through the items of an array - a common task in coding.
import flash.events.KeyboardEvent;
var myColours:ColorTransform = mcDisplay.transform.colorTransform;
var id:int;
var coloursArray:Array = new Array( );
coloursArray = ["#711B06", "#510572", "#D36D0A", "#D6075A"];
stage.addEventListener(KeyboardEvent.KEY_DOWN,colourChange);
function colourChange(event:KeyboardEvent):void{ if (event.keyCode == 81);{ id++; if (id > 2) id = 0; myColours.color = coloursArray [id]; mcDisplay.color.colorTransform = myColours;}}
thanks! :)
babyginops 1 year ago
hii i wonder if u could help? ive tried using this code to change the colour of a movie clip but keep getting this msg 'TypeError: Error #1010: A term is undefined and has no properties.at ActionscriptProject1_fla::MainTimeline/colourChange()'
the code that i used is:
babyginops 1 year ago