Solved

Flex: Positioning RadioButtons x position according to the selected button in ButtonBar

Posted on 2014-01-19
3
429 Views
Last Modified: 2014-01-20
Hello, here is my problem explained with an image:
problem with positionYou can see when selecting my second button it makes a scroll-text-resize area, that should not be there.
Here is my code:
<mx:ToggleButtonBar id="mapTypeToggleButtonBar" right="5" top="5" horizontalGap="0" selectedIndex="1" fontSize="10" toggleOnClick="false" dataProvider="{mapTypeViewStack}" />
	<mx:ViewStack id="mapTypeViewStack" y="{mapTypeToggleButtonBar.y + mapTypeToggleButtonBar.height}" width="{mapTypeToggleButtonBar.width}" x="{mapTypeToggleButtonBar.x}">
		<mx:Canvas id="mapView" label="Map" width="100%" height="100%" x="{mapTypeToggleButtonBar.x}">
			<s:RadioButton id="mapTerrain" label="Terrain" fontSize="10" x="{getmapTypeToggleButtonBarSelectedButtonX(mapTypeToggleButtonBar.selectedIndex)}"/>
		</mx:Canvas>
		<mx:Canvas id="satelliteView" label="Satellite" width="100%" height="100%">
			<s:RadioButton id="satelliteLabels" fontSize="10" label="Labels" x="{getmapTypeToggleButtonBarSelectedButtonX(mapTypeToggleButtonBar.selectedIndex)}"/>
		</mx:Canvas>
	</mx:ViewStack>

Open in new window


			public function getmapTypeToggleButtonBarSelectedButtonX(value:int) : int
			{
				var i:int;
				var st:int = mapTypeToggleButtonBar.selectedIndex;
				var hold:int;
				for (i = 0; i < st; i++)
					{
						hold += mapTypeToggleButtonBar.getChildAt(mapTypeToggleButtonBar.selectedIndex).width;
					}
				return hold
			}

Open in new window


How can I fix this, or is there a simpler way?

Thank you in advance.
0
Comment
Question by:JoachimPetersen
  • 3
3 Comments
 

Author Comment

by:JoachimPetersen
Comment Utility
Added scale for the radiobutton below:
<mx:ToggleButtonBar id="mapTypeToggleButtonBar" right="5" top="5" horizontalGap="0" selectedIndex="1" fontSize="10" toggleOnClick="false" dataProvider="{mapTypeViewStack}" />
	<mx:ViewStack id="mapTypeViewStack" y="{mapTypeToggleButtonBar.y + mapTypeToggleButtonBar.height}" width="{mapTypeToggleButtonBar.width}" x="{mapTypeToggleButtonBar.x}">
		<mx:Canvas id="mapView" label="Map" width="100%" height="100%" x="{mapTypeToggleButtonBar.x}">
			<s:RadioButton id="mapTerrain"
						   x="{getmapTypeToggleButtonBarSelectedButtonX(mapTypeToggleButtonBar.selectedIndex)}"
						   y="2.5" label="Terrain" width="{mapTypeToggleButtonBar.getChildAt(mapTypeToggleButtonBar.selectedIndex).width/3 + mapTypeToggleButtonBar.getChildAt(mapTypeToggleButtonBar.selectedIndex).width}" scaleY="{mapTypeToggleButtonBar.getChildAt(mapTypeToggleButtonBar.selectedIndex).width/satelliteLabels.width}" scaleX="{mapTypeToggleButtonBar.getChildAt(mapTypeToggleButtonBar.selectedIndex).width/satelliteLabels.width}"/>
		</mx:Canvas>
		<mx:Canvas id="satelliteView" label="Satellite" width="100%" height="100%">
			<s:RadioButton id="satelliteLabels"
						   x="{getmapTypeToggleButtonBarSelectedButtonX(mapTypeToggleButtonBar.selectedIndex)}"
						   y="2.5" label="Labels" width="{mapTypeToggleButtonBar.getChildAt(mapTypeToggleButtonBar.selectedIndex).width/3 + mapTypeToggleButtonBar.getChildAt(mapTypeToggleButtonBar.selectedIndex).width}" scaleY="{mapTypeToggleButtonBar.getChildAt(mapTypeToggleButtonBar.selectedIndex).width/satelliteLabels.width}" scaleX="{mapTypeToggleButtonBar.getChildAt(mapTypeToggleButtonBar.selectedIndex).width/satelliteLabels.width}"/>
		</mx:Canvas>
	</mx:ViewStack>

Open in new window

This still does not work, as when you start the application it will not scale the first visible radiobutton to correct size before you press the buttonbar so it refreshes the first button.
How can I fix this?

Is there an easier way?
0
 

Accepted Solution

by:
JoachimPetersen earned 0 total points
Comment Utility
scale down radiobutton is the solution I found
0
 

Author Closing Comment

by:JoachimPetersen
Comment Utility
worked
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now