Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-09-2012, 04:11 PM   #1
Registered User
Join Date: Mar 2011
Posts: 24
Default problem - piano roll on stage using an array

hello there, I am trying to create a piano roll of 25 keys using an array which uses just 1 movieclip for the white keys which is duplicated across the screen 25 times and renamed in the array to a1, b1, c1, d1, e1, f1. I have never properly tried to do this with a single item being used multiple times before.
Could anyone please help? Each key is approx 45 pixels in width.

Heres all what i have so far
ActionScript Code:
stop(); var keys:Array = [keys_mc]; var xPosition:Number = 50; var yPosition:Number = 15; for(i=0;i<button.length;i++)     {             } keys_mc.addEventListener(MouseEvent.CLICK, clickHandler); function clickHandler(event:MouseEvent):void {    gotoAndStop("keyDown"); }

Any help is appreciated.
nolimit966 is offline   Reply With Quote
Old 02-09-2012, 05:28 PM   #2
Senior Member
henke37's Avatar
Join Date: Mar 2009
Location: Sweden
Posts: 10,886
Send a message via Skype™ to henke37

You just need basic geometry. You already have the loop structure down, so it is just a matter of writing the body.

The body needs to update the position variable as it progresses, so increment said variable with the width + padding.

Piano keyboards are fun in that they have these black keys wedged between the other keys. You can deal with this rather easily, just measure the width carefully so that the overlap is allowed to happen.
Signature: I wrote a pair of articles about the timeline.
henke37 is offline   Reply With Quote
Old 02-09-2012, 07:26 PM   #3
Registered User
Join Date: Mar 2011
Posts: 24

cheers man! That worked but im not too good at Geometry. I added the following to my for loop but its not really worked too well. It displays the key but its right at the top right of the page. I need a row of 25 keys which are 45 pixels wide span across the bottom of my scene.
Here is what i used:
ActionScript Code:
for(var number:Number = 0; number < keysArray.length; number++)     {     canvas.addChild(keysArray[number]);//adds the elements of the array to the stage/canvas     keysArray[number].itemAngle = Math.PI * 2 / keysArray.length * number; //placing the item on the stage in position     // canvas.setChildIndex(keysArray[number], number);     }
Can you help please?

Thank you! :-)!
nolimit966 is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 01:52 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.