bogdan_raduta
asked on
How to change the states in Adobe Flex 3
Hello,
I`m really new to Flex and ActionScript so please be patient with me.
I want to implement this script: http://gmaps-samples-flash.googlecode.com/svn/trunk/demos/TabNavigatorInfoWindow /srcview/index.html
...that is doing this "magic": http://gmaps-samples-flash.googlecode.com/svn/trunk/demos/TabNavigatorInfoWindow /TabNavigatorInfoWindow.ht ml#
...but I want to tweak it a little on InfoWindowTabbedComponent. To be more precise I`m trying to insert buttons in that tab, and when you click one the state will change.
I don`t know why my code is not working...you can see it in the attachment.
I`m really new to Flex and ActionScript so please be patient with me.
I want to implement this script: http://gmaps-samples-flash.googlecode.com/svn/trunk/demos/TabNavigatorInfoWindow /srcview/index.html
...that is doing this "magic": http://gmaps-samples-flash.googlecode.com/svn/trunk/demos/TabNavigatorInfoWindow /TabNavigatorInfoWindow.ht
...but I want to tweak it a little on InfoWindowTabbedComponent.
I don`t know why my code is not working...you can see it in the attachment.
package {
import flash.events.Event;
import flash.events.MouseEvent;
import mx.containers.Panel;
import mx.containers.TabNavigator;
import mx.containers.VBox;
import mx.controls.Button;
import mx.core.UIComponent;
public class InfoWindowTabbedComponent2 extends UIComponent
{
public function InfoWindowTabbedComponent2() {
// Add body text
var tabNavigator:TabNavigator = new TabNavigator();
tabNavigator.width = 290;
tabNavigator.height = 150;
//Here I`m creating 3 tabs inside TabNagivator
tabNavigator.addChild(createTab("Utile"));
tabNavigator.addChild(createTab("Cultura"));
tabNavigator.addChild(createTab("Istorie"));
tabNavigator.addChild(createTab("Link"));
addChild(tabNavigator);
addChild(createTab("Parent"));
cacheAsBitmap = true;
}
//Change state function
public function changeState():void
{
currentState = "est";
}
//Create a tab inside TabNavigator
public function createTab(label:String):VBox
{
var tab:VBox = new VBox();
tab.label = label;
var inside:Panel = new Panel();
var link:Button;
inside.width = 280;
inside.height = 100;
inside.setStyle("borderStyle", "none");
//If the user clicks the Link tab and inside that it will click the button, the state must change
if (label=="Link")
{
link = new Button;
link.id = "lnkGoogle";
link.label = "Google";
link.addEventListener(MouseEvent.CLICK, changeState);
//add the button to the tab
inside.addChild(link);
//add the tab to the TabNavigator
tab.addChild(inside);
return tab;
}
}
}
ASKER
Thank you for your answer but is not working. I`m getting this error: 1119: Access of possibly undefined property currentState through a reference with static type flash.display:DisplayObjec tContainer .
As you can see in the image attached, the "est" state is the start state and the "test" state is the one with the problem.
1.PNG
As you can see in the image attached, the "est" state is the start state and the "test" state is the one with the problem.
1.PNG
Let's say your mxml file named TabExample.mxml (I can't see the name of the file on the image) then instead of parent.currentState, do TabExample.currentState. Don't forget to add import for TabExample.
ASKER
shmeltex, can you please tell me how can I import it?
You need to add one more import statement below package { line with other import statements in InfoWindowTabbedComponent2 .as file like this:
import TabExamples;
import TabExamples;
ASKER
After I added this function (my mxml is called "TabNavigatorInfoWindow.") :
public function changeState():void { TabNavigatorInfoWindow.cur rentState = 'est'; }
I`m getting this error: 1119: Access of possibly undefined property currentState through a reference with static type Class.
Let me remind you (I don`t know if it helps) that this function along with that script posted on
my first comment are located in a ".as" file. Do you want me to attach the full project? Maybe it will more easier for you to to help me.
Thank you,
Bogdan
public function changeState():void { TabNavigatorInfoWindow.cur
I`m getting this error: 1119: Access of possibly undefined property currentState through a reference with static type Class.
Let me remind you (I don`t know if it helps) that this function along with that script posted on
my first comment are located in a ".as" file. Do you want me to attach the full project? Maybe it will more easier for you to to help me.
Thank you,
Bogdan
Bogdan,
Just to make sure, you do have "import TabNavigatorInfoWindow;" statement in .as file? If you do have it and still getting error, please post TabNavigatorInfoWindow.mxm l.
Just to make sure, you do have "import TabNavigatorInfoWindow;" statement in .as file? If you do have it and still getting error, please post TabNavigatorInfoWindow.mxm
ASKER
Shmeltex,
Is not working so I uploaded my project on my server(here I can`t upload password protected files, and I don`t want it to be available to the public)
The address: www.epic.droopy.ro/project.zip
The password is: exp-exch
Is not working so I uploaded my project on my server(here I can`t upload password protected files, and I don`t want it to be available to the public)
The address: www.epic.droopy.ro/project.zip
The password is: exp-exch
ASKER
I changed the password because someone just told me that this discussion can be viewed even if you don`t have an account here. I have sent you the new password.
ASKER
Later edit: Seems that there`s no way for sending PM`s or editing a post.
Can I send you an email or something?
Can I send you an email or something?
Bogdan,
Send the password to shmeltex at asdasd.ru
Send the password to shmeltex at asdasd.ru
ASKER
Done
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, but it still doesn`t work. I changed everything you said, but when I`m clicking the button from that Tab, the state is not changing.
I have uploaded the new source, maybe you can see if there`s something wrong.
Link:www.epic.droopy.ro/projectNew.zip
The password is the same.
Thank you again for helping me.
I have uploaded the new source, maybe you can see if there`s something wrong.
Link:www.epic.droopy.ro/projectNew.zip
The password is the same.
Thank you again for helping me.
Bogdan,
Add an argument to function changeState and it should do the trick:
public function changeState( e:Event ):void
Add an argument to function changeState and it should do the trick:
public function changeState( e:Event ):void
ASKER
It worked! Thank you so much! You deserve more than 500 points, because you`re the only one from the whole internet who helped me. I didn`t find the answer not even in adobe forums.
Thank you again, I can`t express how happy I am.
Thank you again, I can`t express how happy I am.
ASKER
He really deserve more points because he`s the only one who helped me.
Thank you for kind words! Glad to help!
if it's in the parent of this container, you could try:
parent.currentState = 'est';