I have a problem displaying scrollbars for my Flex Application... I tried a basic very application with a canvas, but the scrollbars never appear on the browser window athough the canvas is much bigger than what can fit on the screen. Can someone please help? Here's my code :
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<mx:Canvas id="MyCanvas" height="2500" width="2000" verticalScrollPolicy="auto"
horizontalScrollPolicy="auto" backgroundColor="black" symbolColor="#000000"
contentBackgroundColor="#080808"/>
</s:Application>
Do you want the scroll bar in your canvas? Or in your main application? If you want scroll bars in your canvas, just add content that extends beyond the height and width of the canvas. It will "magically" add them, because that is way MX/Halo components role.
If you want scrollbars in your main application, you're going to have to add them manually, using a scroller component and a group. Conceptually something like this:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<s:Scroller height="100" width="100">
<s:Group width="100%" height="100%" clipAndEnableScrolling="true">
<mx:Canvas id="MyCanvas" height="2500" width="2000" verticalScrollPolicy="auto"
horizontalScrollPolicy="auto" backgroundColor="black" symbolColor="#000000"
contentBackgroundColor="#080808"/>
</s:Group>
</s:Scroller>
</s:Application>
In my experience you need to specify a fixed height and/or width on the scroller for the scroll bars to show up. Also be sure to clipAndenableScrolling on the group inside the scroller, or else the content will display beyond the scroller's viewport--which is kind of defeats the purpose.
Some good info from Adobe.
I got it to wrok just fine using the scroller/group around my applications mxml, i tried someone elses scroller skin def but it didnt work.
the main thing is to set all the heights and widths to 100% for the application, scroller & group.
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" height="100%>
<s:Scroller height="100%" width="100%" horizontalScrollPolicy="on" verticalScrollPolicy="on">
<s:Group left="0" right="0" top="0" bottom="0">
<!--...mxml....-->
</s:Group>
</s:Scroller>
</s:Application>
In Flex 4+ (spark) you don't use "scrollPolicies" anymore. The MX canvas still does, so if your canvas contents grow beyond 2500x2000, they will scroll.
For your entire APP to have a scroller you need to create a skin for the Application and wrap the "contentGroup" in a tag.
See: http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf62d75-7fff.html for more information on adding a scroller to a spark application
Related
I'm using the following code to load an image to the screen:
<s:Scroller xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
width="100%"
height="100%">
<s:VGroup width="100%" horizontalAlign="center" paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10" verticalAlign="top">
<s:Label width="100%" text="Being Active" fontSize="14" fontFamily="Black"/>
<s:Image fillMode="scale" smooth="true" scaleMode="letterbox" verticalCenter="0" horizontalCenter="0" width="100%" source="#Embed('assets/img/q3/q3c1all.png')"/>
....
....
</s:VGroup>
</s:Scroller>
In the attached image, it has three images
1. Builder view
2. final design (what designer expects)
3. rendered output (what users will see)
Because of the scaleMode letterbox, there is lots of space above and below image is blanked. And this breaks out the layer. Can someone suggest how can I make the out put looks like design preview (titled Requirement)
How to scale the image proportionately without distorting (like its done in CSS).
To those who struggle with this issue - the solution is to use which will give you full control over the bitmap. One thing to note is - if you are planning to use interaction / events with the image, wrap it inside a container and add click event to it.
I dont know if this is best solution, but it worked for me :)
Scrollbar is not visible in my flex web application when I change the size of window,
when i am slightly changing my window size to little bit smaller then, it is not showing any scrollbar and some part of my screen is hidden.
I have already used verticalScrollPolicy and horizontalScrollPolicy in my main mxml file but no effect.Please help me out here.
this is the code.
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
xmlns:controller="controller.*"
xmlns:view="view.*"
width="1000" height="600"
backgroundColor="#FF9900"
verticalScrollPolicy="auto"
horizontalScrollPolicy="auto">
Thanks in advance
change the layout to vertical after that your application tag will going to be like that
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
xmlns:controller="controller.*"
xmlns:view="view.*"
width="1000" height="600"
backgroundColor="#FF9900"
verticalScrollPolicy="auto"
horizontalScrollPolicy="auto">
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Canvas width="100%" height="100%">
<mx:Canvas backgroundColor="#A8A8A8" height="100%" right="0" top="0" width="100">
</mx:Canvas>
</mx:Canvas>
<mx:VBox width="800" height="100%" >
</mx:VBox>
</mx:Application>
My code above works absolutely fine, until i resize my browser window to a size below 800px width.
When the browser window is make of lesser width than 800px, the canvas with background color #A8A8A8 is on the right of the window, but the problem is, when I move the scroll bar, the canvas should remain on the right of the window. Which does not happen, and that is what my problem is.
How can I solve this issue. What should I do to keep my canvas be on the right=0 all the time.
Plz help me.
Regards
Zeeshan
Your canvas get scrolled with the application. It keeps right="0", but right border is shifted off screen. You can disable scrolling with <mx:Application horizontalScrollPolicy="off"> and VBox below should not have fixed width of 800.
ive been pondering how to create the same type of resizing that acrobat connect does. i did read the documentation of percentage sizing. and i have implemented it. but its not how i want it to look.
to see an example : https://admin.na3.acrobat.com/_a204547676/flextras/
sorry Jeffrey to use you as an example. :)
just try to resize your window and see it... thats what im looking for .
any hints guys?
Given your code sample; the button is not given a height or width; so Flex sizes it automatically used a fixed width. Give the button a percentage width or height and it should resize appropriately as the screen changes.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" backgroundColor="#FFFFFF">
<s:BorderContainer width="40%" height="70%" y="10" horizontalCenter="0">
<mx:Image height="100%" width="100%" id="img" source="http://upload.wikimedia.org/wikipedia/en/thumb/a/ab/Apple-logo.png/125px-Apple-logo.png" horizontalCenter="0"/>
</s:BorderContainer>
<s:Button y="543" horizontalCenter="0" label="start" width="40%" height="30%"/>
</s:Application>
ok i have tried it. but its not the result i am looking for. if you keep resizing back and forth the acrobat app you can see the entire app resizing compared to the above example.
its not quite the same.
I'm currently learning Flex, and am having the hardest time getting scroll bars to work. In short, I'm making a giant form for users to fill out, contained within a viewstack component. The user will type up information in one view, and it will be displayed in the other. But right now in the first canvas I have components that run off the screen and flex doesn't automatically add a scroll bar, so I added 'verticalScrollPolicy="on"' to my canvas. Now, while it gives me a scroll bar, it gives me an empty scroll bar. I still cannot move it up or down, meaning components are still trapped off the bottom of my screen. Am I missing something simple?
Edit - I'm using Adobe Flex Builder 3, and the components it lets you drag in. http://img12.imageshack.us/img12/218/problem1f.jpg This is a picture of the problem, and i guess relavent code would be.
<mx:Application xmlns:mx="adobe.com/2006/mxml" layout="absolute" width="830" height="835">
<mx:ViewStack x="10" y="72" id="viewstack1" width="790" height="751" >
<mx:Canvas label="Design Mode" width="100%" height="100%" verticalScrollPolicy="on" horizontalScrollPolicy="on" >
(Components inside)
</mx:Canvas>
I think the problem is in the way the content in your canvas determines it's height.
If I do this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:ViewStack width="500" height="500">
<mx:Canvas width="100%" height="100%">
<mx:Canvas width="100" height="1000" backgroundColor="#ededed" />
</mx:Canvas>
</mx:ViewStack>
</mx:Application>
I get scrollbars - Canvas has a default horizontalScrollPolicy and verticalScrollPolicy of auto, meaning it'll show the scrollbars as needed. I think, for whatever reason, the outer canvas isn't detecting that the content is taller than it should be.
if it can help some one : some related problem