Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-09-2009, 04:14 PM   #1
NCarolina
Registered User
 
Join Date: Nov 2009
Posts: 4
Default Why are my buttons not working?

My XML is being called but my buttons are not working properly so the text fields are not populated. The rollout rollover alpha is not working. Any suggestions? This has got to be so simple.

Here is my script:

ActionScript Code:
stop(); var buttons:Array = [box1_btn, box2_btn, box3_btn]; for (var i = 0; i<buttons.length; i++) {     buttons[i].onRollOut = function() {         this._alpha = 100;     };     buttons[i].onRollOver = function() {         this._alpha = 50;     }; } var divisionsXML:XML = new XML(); var office:Array = new Array(); var leadership:Array = new Array(); var overview:Array = new Array(); var mission:Array = new Array(); var organization:Array = new Array(); for (var i = 0; i<3; i++) {     buttons[i].id = i;     buttons[i].onRelease = function() {         this._parent.loadOffice(this.id);     }; } function loadOffice(i) {     officetf.text = office[i];     leadershiptf.text = leadership[i];     overviewtf.text = overview[i];     missiontf.text = mission[i];     organizationtf.text = organization[i]; } divisionsXML.ignoreWhite = true; divisionsXML.load("divisions.xml"); divisionsXML.onLoad = divisionsLoad; function divisionsLoad() {     var divisionsNum:Number = divisionsXML.firstChild.childNodes.length;     for (var i = 0; i<divisionsNum; i++) {         var officeNode:XMLNode = divisionsXML.firstChild.childNodes[i].childNodes[0];         office.push(officeNode.firstChild.nodeValue);         var leadershipNode:XMLNode = divisionsXML.firstChild.childNodes[i].childNodes[1];         leadership.push(leadershipNode.firstChild.nodeValue);         var overviewNode:XMLNode = divisionsXML.firstChild.childNodes[i].childNodes[2];         overview.push(overviewNode.firstChild.nodeValue);         var missionNode:XMLNode = divisionsXML.firstChild.childNodes[i].childNodes[3];         mission.push(missionNode.firstChild.nodeValue);         var organizationNode:XMLNode = divisionsXML.firstChild.childNodes[i].childNodes[4];         organization.push(organizationNode.firstChild.nodeValue);     } }
NCarolina is offline   Reply With Quote
Old 11-09-2009, 04:53 PM   #2
magicTuscan
Registered User
 
Join Date: Nov 2009
Posts: 46
Default

WRONG:
ActionScript Code:
var buttons:Array = [box1_btn, box2_btn, box3_btn]; buttons[i]

RIGHT
ActionScript Code:
var buttons:Array = ["box1_btn", "box2_btn", "box3_btn"]; this[buttons[i]]
magicTuscan is offline   Reply With Quote
Old 11-09-2009, 06:05 PM   #3
NCarolina
Registered User
 
Join Date: Nov 2009
Posts: 4
Default

Thank you for your response. I tried your suggestion and it doesn't appear to work either.
NCarolina is offline   Reply With Quote
Old 11-10-2009, 04:28 AM   #4
raghu_thejus
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 259
Thumbs up

u can do like this

Code:
 
for (var i = 1; i<4; i++) {
    this["box"+i+"_btn"].onRollOut = function() {
        this._alpha = 100;
    };
    this["box"+i+"_btn"].onRollOver = function() {
       this._alpha = 50;
   };
}
__________________
Learn from your mistakes/fault.Never make any mistake/fault....
raghu_thejus is offline   Reply With Quote
Old 11-10-2009, 08:56 AM   #5
magicTuscan
Registered User
 
Join Date: Nov 2009
Posts: 46
Default

Quote:
Originally Posted by NCarolina View Post
My XML is being called but my buttons are not working properly so the text fields are not populated. The rollout rollover alpha is not working. Any suggestions? This has got to be so simple.

Here is my script:

ActionScript Code:
stop(); var buttons:Array = [box1_btn, box2_btn, box3_btn]; for (var i = 0; i<buttons.length; i++) {     buttons[i].onRollOut = function() {         this._alpha = 100;     };     buttons[i].onRollOver = function() {         this._alpha = 50;     }; } var divisionsXML:XML = new XML(); var office:Array = new Array(); var leadership:Array = new Array(); var overview:Array = new Array(); var mission:Array = new Array(); var organization:Array = new Array(); for (var i = 0; i<3; i++) {     buttons[i].id = i;     buttons[i].onRelease = function() {         this._parent.loadOffice(this.id);     }; } function loadOffice(i) {     officetf.text = office[i];     leadershiptf.text = leadership[i];     overviewtf.text = overview[i];     missiontf.text = mission[i];     organizationtf.text = organization[i]; } divisionsXML.ignoreWhite = true; divisionsXML.load("divisions.xml"); divisionsXML.onLoad = divisionsLoad; function divisionsLoad() {     var divisionsNum:Number = divisionsXML.firstChild.childNodes.length;     for (var i = 0; i<divisionsNum; i++) {         var officeNode:XMLNode = divisionsXML.firstChild.childNodes[i].childNodes[0];         office.push(officeNode.firstChild.nodeValue);         var leadershipNode:XMLNode = divisionsXML.firstChild.childNodes[i].childNodes[1];         leadership.push(leadershipNode.firstChild.nodeValue);         var overviewNode:XMLNode = divisionsXML.firstChild.childNodes[i].childNodes[2];         overview.push(overviewNode.firstChild.nodeValue);         var missionNode:XMLNode = divisionsXML.firstChild.childNodes[i].childNodes[3];         mission.push(missionNode.firstChild.nodeValue);         var organizationNode:XMLNode = divisionsXML.firstChild.childNodes[i].childNodes[4];         organization.push(organizationNode.firstChild.nodeValue);     } }
Have you realised that you are writing your code in as2 format.
This is why it's not working.

WRONG:
ActionScript Code:
buttons[i].onRollOut = function() {         this._alpha = 100;     };

RIGHT:
ActionScript Code:
this[buttons[i]].addEventListener(MouseEvent.MOUSE_OVER, doRollOver, false, 0, true); this[buttons[i]].addEventListener(MouseEvent.MOUSE_OUT, doRollOut, false, 0, true); private function doRollOver(e : MouseEvent) : void {   e.currentTarget.alpha = 1; } private function doRollOut(e : MouseEvent) : void {   e.currentTarget.alpha = .5; }
magicTuscan is offline   Reply With Quote
Old 11-10-2009, 01:41 PM   #6
NCarolina
Registered User
 
Join Date: Nov 2009
Posts: 4
Default

Thank you both for your help!
NCarolina is offline   Reply With Quote
Reply


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 09:57 PM.

///
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.