Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Flash (all versions) section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 23rd, 2007, 09:27 PM
Registered User
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default [Flash8 AS2] Create buttons with AS2

Hello, I got this code from a book, but cant understand why do I need the second var to create and show the buttons.
To resume, this code creates four buttons just with AS.
Shouldn't just one var should be enough?
I tried with just one var, but it just show one button, instead the four of them.
Thanks.


var baseMovieClip:MovieClip = _level0;
var tempMovieClipHolder:MovieClip;
for (var i:Number = 0; i < 5; i++)
{
// Create a movie clip
baseMovieClip.createEmptyMovieClip(“buttonClip† + i, ;
baseMovieClip.getNextHighestDepth());
tempMovieClipHolder = baseMovieClip[“buttonClip” + i];
// Assign an ID to a timeline variable tied to the button
tempMovieClipHolder.buttonID = i;
// Draw something inside the button so it can be seen and clicked on
tempMovieClipHolder.lineStyle(1, 0x333333);
tempMovieClipHolder.beginFill(0x6666AA);
tempMovieClipHolder.moveTo(0, 0);
tempMovieClipHolder.lineTo(50, 0);
tempMovieClipHolder.lineTo(50, 25);
tempMovieClipHolder.lineTo(0, 25);
tempMovieClipHolder.lineTo(0, 0);
// Position the button
tempMovieClipHolder._y = 10;
tempMovieClipHolder._x = i * 60 + 10;
// Make the button clickable. Pass along the ID that was assigned
// to the button’s timeline
tempMovieClipHolder.onRelease = function()
{
handleButtonClick(this.buttonID);
}
}
function handleButtonClick(buttonID:Number)
{
trace(“Clicked on button number: “ + buttonID);
}

stela





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Check Boxes/Option buttons/Option Group hewstone999 Access VBA 1 March 14th, 2008 07:25 AM
Create generic XSL Template to create table Venkatachalapathy XSLT 5 March 11th, 2008 07:49 AM
create buttons dynamically on webpage rocksbhavesh ASP.NET 1.0 and 1.1 Professional 5 April 19th, 2007 05:20 PM
buttons over and under rahzan Access VBA 4 April 7th, 2005 11:35 AM
'ok buttons' hiker Beginning VB 6 2 March 22nd, 2004 02:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.