Adobe Dreamweaver Forums



Last 10 THreads :         Adobe Flash 10 kills Wimpy (Last Post : ClubEXL.com - Replies : 82 - Views : 955 )           »          static sound (Last Post : 21n9 - Replies : 10 - Views : 11 )           »          flash loader reappears after movie plays (Last Post : kglad - Replies : 4 - Views : 5 )           »          Flex compiler in FlexBuilder and Flex SDK (Last Post : 2009 Matt - Replies : 4 - Views : 5 )           »          Is file too large? (Last Post : kglad - Replies : 1 - Views : 2 )           »          Embed files in a projector (Last Post : Sean Wilson - Replies : 1 - Views : 2 )           »          problems linking PDFs (Last Post : Mantzi - Replies : 2 - Views : 3 )           »          VERY newbie question (Last Post : cashcrate13 - Replies : 0 - Views : 1 )           »          Undesired offset with Flash object (Last Post : TC2112 - Replies : 1 - Views : 2 )           »          Code that can effect two movie clips (Last Post : NedWebs - Replies : 1 - Views : 2 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-20-2008, 09:23 PM
R1R 7humbs
 
Posts: n/a
Diggs:
Default Changing viewState via a dynamically added button

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();
}



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-21-2008, 12:42 AM
*gsb*
 
Posts: n/a
Diggs:
Default Re: Changing viewState via a dynamically added button

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.


Reply With Quote
  #3 (permalink)  
Old 11-21-2008, 04:23 PM
R1R 7humbs
 
Posts: n/a
Diggs:
Default Re: Changing viewState via a dynamically added button

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();
}

Reply With Quote


  #4 (permalink)  
Old 11-21-2008, 04:42 PM
R1R 7humbs
 
Posts: n/a
Diggs:
Default Re: Changing viewState via a dynamically added button

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

Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 12:19 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk