Creating Colouring-in program

Need actionscript to load temporary movie clip

Page 1 of 1

1 Replies - 1379 Views - Last Post: 26 September 2006 - 12:28 AM

#1 mgraham  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 03-August 06

Creating Colouring-in program

Posted 18 September 2006 - 05:45 PM

Hi there,

can anyone help guide me in the right direction... I have followed the tutorial on the above, which was in the Macromedia 8, Flash 8 actionscript,training from the source text boo, Jobe & Makar.

Below is code for the application...but what I would like to do is have a combo box?, with drop down menu that loads 2 other images. Can anyone tell me how to do this?

much appreciated MG
import flash.display.BitmapData;
import flash.filters.DropShadowFilter;
import flash.geom.Matrix;

var coloringPageBmp:BitmapData;// = BitmapData.loadBitmap("ColoringPage");
var colorSelectorBmp:BitmapData = BitmapData.loadBitmap("ColorSelector");
//load man1.gif image
var imageTemporaryClip:MovieClip = this.createEmptyMovieClip("imageTemporaryClip", this.getNextHighestDepth());
var imageLoader:MovieClipLoader = new MovieClipLoader();

var coloringPageClip:MovieClip = this.createEmptyMovieClip("coloringPageClip", this.getNextHighestDepth());//add colouring page bitmap content to a movie clip

var colorPaletteClip:MovieClip = this.attachMovie("ColorPalette", "colorPaletteClip", this.getNextHighestDepth());//load colour palette to empty movieclip, attach colour selector to it 
colorPaletteClip.createEmptyMovieClip("selectorClip", colorPaletteClip.getNextHighestDepth());
colorPaletteClip.selectorClip.attachBitmap(colorSelectorBmp, colorPaletteClip.selectorClip.getNextHighestDepth());
colorPaletteClip.selectorClip._y = 40;
colorPaletteClip.selectorClip._x = colorPaletteClip._width / 2 - colorPaletteClip.selectorClip._width / 2;
colorPaletteClip.filters = [new DropShadowFilter(10, 45, 0x000000, 50, 10, 10)];

var selectedColor:Number = 0xFFFFFF; 

colorPaletteClip.selectorClip.onPress = function():Void {//gets pixel value so colour selector can assign selected Color for colorPaletteClip.selectorClip 
	selectedColor = colorSelectorBmp.getPixel(colorPaletteClip._xmouse - colorPaletteClip.selectorClip._x, colorPaletteClip._ymouse - colorPaletteClip.selectorClip._y);

colorPaletteClip.titleBarClip.onPress = function():Void {//makes colour palette draggable 

colorPaletteClip.titleBarClip.onRelease = function():Void {

colorPaletteClip.titleBarClip.onReleaseOutside = colorPaletteClip.titleBarClip.onRelease;

coloringPageClip.onPress = function():Void {//selected colour applied as flood fill
	if(coloringPageBmp.getPixel(_xmouse, _ymouse) == 0x000000) { 
	coloringPageBmp.floodFill(_xmouse, _ymouse, selectedColor);

function onloadInit(imageClip:MovieClip):Void {//onload function draws image to bitmapimage data object, attaching to movieclip
	coloringPageBmp = new BitmapData(imageClip._width, imageClip._height, false, 0xFFFFFFFF);
	coloringPageBmp.draw(imageTemporaryClip, new Matrix());
	imageTemporaryClip._visible = false;
	coloringPageClip.attachBitmap(coloringPageBmp, 1);

Is This A Good Question/Topic? 0
  • +

Replies To: Creating Colouring-in program

#2 pioSko  Icon User is offline

  • still.dreaming
  • member icon

Reputation: 23
  • View blog
  • Posts: 1,888
  • Joined: 06-June 03

Re: Creating Colouring-in program

Posted 26 September 2006 - 12:28 AM

G'Day.. A drop down element can be dragged from the Components panel in Flash. These are pre-defined, ready-to-go components that you drag-and-drop onto the stage then code around. Main components are User Interface components and that's where you'll find a drop down panel.

Drag a drop down component onto the stage and name it (eg. dropDown)

There's a number of ways of adding items to the drop down menu. I find creating an array then populating the drop down with it using a function, the easiest since you can add more elements dynamically just by adding them to the array.

The drop dwon then has to be given a "change handler" to execute a function when ever the user changes an element from the drop down list.

And it all looks something like.. this:
var item:Array = new Array("red", "white", "blue");

function populateDropDown(src:Array):Void {
	for (var i = 0; i < src.length; i++) {
		dropDown.addItem({label:src[i], data:src[i]});

dropDown.changeHandler = function() {


// Add another entry to the array and populate the drop down

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1