![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
Hi,
I've attached a small function that uses an XML file via to create buttons. The XML file has information for the name of the button, it's vertical position and what state the application should go to upon clicking the button. I can get the application to do everything but change states when I click the button. I've tried several different ideas with no success (I've also tried hard coding the state just to make sure there wasn't an issue with the data from the XML file). private function onResult7(oEvent:ResultEvent):void{ var xmlCatalog7:XML = XML(oEvent.result); _xlcCatalog7 = new XMLListCollection(xmlCatalog7.button); var b1:Button = new Button(); b1.width=135; b1.height=27; b1.x = 5; b1.y = xmlCatalog7.button[0].y_position; b1.label = xmlCatalog7.button[0].name; b1.addEventListener(MouseEvent.CLICK, switchState); function switchState(event:Event):void{ currentState = xmlCatalog7.button[0].view_state; } application.addChild(b1); _xlcCatalog7.refresh(); oEvent.preventDefault(); } |
| Sponsored Links |
|
|||
|
Hummm....
I think you need to change your button function like this: Application.application.currentState = xmlCatalog7.button[0].view_state; ....and do not forget to import mx,core,Application. |
|
|||
|
Thanks for the suggestion but it still won't work. It seems like the function
isn't being called when the button is clicked. I pasted updated code based upon you suggestion (you'll also be able to see other things I've tried - commented out). Thanks. private function onResult7(oEvent:ResultEvent):void{ var xmlCatalog7:XML = XML(oEvent.result); //_xlcCatalog7 = new XMLListCollection(xmlCatalog7.report); //wrap the XMLList in a collection var b1:Button = new Button(); b1.width=135; b1.height=27; b1.x = 5; b1.y = xmlCatalog7.report[0].y_positon; b1.label = xmlCatalog7.report[0].name; b1.data = String(xmlCatalog7.report[0].view_state); b1.addEventListener(MouseEvent.CLICK, switch_State); function switch_State(event:Event):void{ //Application.application.currentState = xmlCatalog7.report[0].view_state; //currentState = event.target.data; Application.application.currentState = event.target.data; /* var l1:Label = new Label(); l1.text=event.target.data; canvas = new Canvas(); canvas.addChild(l1); PopUpManager.addPopUp(canvas, this, true); PopUpManager.centerPopUp(canvas); */ } application.addChild(b1); //_xlcCatalog7.refresh(); //oEvent.preventDefault(); } |
|
|||
|
:light;
I figured out what was wrong... there were two problems and one caused the other. The first problem is that I'm retarded. Which is why I didn't notice that the view states are case sensitive and my XML and hard coded values were in a different case than the actual states. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise