02-16-2011 12:19 PM
glad you got it working as a proof of concept. at least you know it works now! so for it only showing up in the Home stage, are you using view components or are you using states?
02-16-2011 12:27 PM
I'm using states except for top swipe which is component.
I do have it set to includeIn="New" - which it doesn't display in, but when I set it to Home it does.
I started reading up but got distracted with some graphical elements I'm trying to finish up, sorry I don't have any other updates for you.
02-16-2011 01:18 PM
dont sweat, i get distracted and digress all the time haha. question, are you running your project as an regular flex project or a mobile project? dont know if thats relavent but thought id ask. anyways my theory is as i think comantis has stated is something might be covering up your toggle switch. so try to set it with weird x and y values (the container) and see if that helps it show up. place it somewhere you know nothing else will be and place it there and see if it shows up.
below is a sample code i wrote up showing that it works using states. when you toggle it switches the states from "home" to "new" but keeps hte toggle visible in both views:
<?xml version="1.0" encoding="utf-8"?>
title="Home" creationComplete="init()" xmlns:mx="library://ns.adobe.com/flex/mx" currentState="Home">
private var toggleSwitch:ToggleSwitch;
private function init():void
toggleSwitch = new ToggleSwitch();
toggleSwitch.selectedLabel = "New";
toggleSwitch.defaultLabel = "Home";
trace("toggleSwitchContainer.numChildren: " + toggleSwitchContainer.numChildren);
private function onSelect(e:Event):void
currentState = ToggleSwitch(e.currentTarget).selectedLabel;
currentState = ToggleSwitch(e.currentTarget).defaultLabel;
this.title = currentState;
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:State name="New" />
<s:State name="Home" />
<mx:UIComponent id="toggleSwitchContainer" x="10" y="10" includeIn="Home, New" />
02-16-2011 01:32 PM
I've tried different background, no background, random locations on top of other elements, off on it's own. I've tried colored background, I've tried it in all the states (only shows in Home).
This might be a hint to you: It displays fine in BOTH states of Home/New if I includeIn="Home, New"
Is your brain tickled yet? Mine's pickled!
02-16-2011 01:37 PM
wow that really is strange lol. my next theory is are the states properly being switched? like is the "New" state active or is another state active. is there something else thats also just in the "New" state along with the mx.UIComponent? the icons you mentioned probably are but im just throwing up ideas at this point haha
ah also try to create a new flex mobile project. and try to run the sample app. maybe its your project that is causing the errors. that way we can weed more stuff out. good luck!
02-16-2011 01:54 PM
I feel it has something to do with my init function.
If I set the set the currentState="New" in my Application it loads the slider just fine within the New state. However, setting the UIComponent to includeIn="Home" and not New while currentState is set to New, it does not render in Home.
To chance states I'm using a "round about" way to do it - I have a component to handle my swipe down nav, and I'm using FlexGlobals.topLevelApplication.currentState to change states as I couldn't get my custom event listeners to work properly so I gave up and went with that - which seems to work for not only changing state but I'm also able to call the functions from topLevelApplication.function()
02-16-2011 02:04 PM
that's weird. i tried running the code i posted in the previous post with the state switching via the toggle and then replaced the currentState with FlexGlobals.topLevelApplication.currentState and got the following error when i tried to toggle:
ArgumentError: Undefined state 'New'.
how are you setting the states in your app?
02-16-2011 02:06 PM
02-16-2011 02:18 PM
Messy way to get it to work also:
includeIn="Home, New" visible.Home="false"
Shows up fine in New. I'll rebuild everything tonight and see if I yield any different results. My init function just doesn't want that to load unless it is also loading in the state the app starts in.