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 March 24th, 2004, 03:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default dynamic buttons

Can somebody help me with some actionscript 1.0. I am trying to create some dynamic links for buttons.

var buttonNames
buttonNames = new Array();
buttonNames = ["cap_content", "cap_advertise"]

function createLinks() {
    var numberOfButtons
    numberOfButtons = buttonNames.length;
    var icounter
    icounter = -1;
    while (++icounter < numberOfButtons) {
    var name
        name = buttonNames[icounter] + "_btn";
        playSection = buttonNames[icounter];
        trace([name]);
        [name].onRelease = function() {
  trace("We are in");
            trace(playSection);
            playCapContent(playSection);
        }
}

I can get the button names to Trace, but my problem lies within the onRelease funtion, I cannot get the button name to relate to the code. The buttons have the same names as shown. I have tried a bunch of different scenerios but nothing seems to work.


Thanks In Advance
__________________
Peace
Mike
http://www.eclecticpixel.com
 
Old March 24th, 2004, 03:45 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default

Mike,

Shouldn't you be using ActionScript 2.0? Forgive me if I'm being a little bossy but you're using an outdated version of ActionScript.

Quote:
quote:Originally posted by harpua
 Can somebody help me with some actionscript 1.0. I am trying to create some dynamic links for buttons.

var buttonNames
buttonNames = new Array();
buttonNames = ["cap_content", "cap_advertise"]

function createLinks() {
    var numberOfButtons
    numberOfButtons = buttonNames.length;
    var icounter
    icounter = -1;
    while (++icounter < numberOfButtons) {
    var name
        name = buttonNames[icounter] + "_btn";
        playSection = buttonNames[icounter];
        trace([name]);
        [name].onRelease = function() {
trace("We are in");
            trace(playSection);
            playCapContent(playSection);
        }
}

I can get the button names to Trace, but my problem lies within the onRelease funtion, I cannot get the button name to relate to the code. The buttons have the same names as shown. I have tried a bunch of different scenerios but nothing seems to work.


Thanks In Advance
Ben Horne
Madison Area Technical College student
-------------------------
http://community.webshots.com/user/valerian114

Go there. I have a lot of awesome photos that I rendered myself

"A Person Who Claims To Be A Flash Junkie Isn't Really A Flash Junkie Unless He Can Prove It"
 
Old March 24th, 2004, 05:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes i would rather be building this in the latest version of Flash but I am on an old Mac G3 350, Flash 2004 will not run on this machine. any clue why the line [name].onRelease = function() will not work? I have about 15 buttons with different functions, figuring this out could help me save a lot of time.


Thanks
Mike
 
Old October 19th, 2004, 07:33 PM
Registered User
 
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

_root["myButtonName"+i].onRelease = function(){

This syntax is called array notation , I believe. They should paste this script on the box if you ask me. It would save scripters days of work.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Buttons,SaveToolStrip, adding records KeviJay VB Databases Basics 2 May 28th, 2008 12:46 PM
Dynamic Buttons in PHP Rayne84 PHP How-To 0 March 16th, 2008 07:31 AM
Dynamic created buttons in Vb.Net remya1000 General .NET 1 December 6th, 2007 04:20 PM
dynamic editable buttons on windows form? frankv25 Pro VB 6 2 March 19th, 2004 10:06 AM
Dynamic Buttons? TSEROOGY Javascript How-To 6 September 4th, 2003 11:38 AM





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