<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; backgroundAttachment</title>
	<atom:link href="http://blog.flexexamples.com/tag/backgroundattachment/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Changing a VBox container&#8217;s background image attachment in Flex</title>
		<link>http://blog.flexexamples.com/2008/01/05/changing-a-vbox-containers-background-image-attachment-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/01/05/changing-a-vbox-containers-background-image-attachment-in-flex/#comments</comments>
		<pubDate>Sat, 05 Jan 2008 21:35:31 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[VBox]]></category>
		<category><![CDATA[backgroundAttachment]]></category>
		<category><![CDATA[backgroundImage]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/05/changing-a-vbox-containers-background-image-attachment-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can set a background image and change its attachment to scrolling or fixed for a Flex VBox container by setting the backgroundImage and backgroundAttachment styles.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/VBox_backgroundAttachment_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/01/05/changing-a-vbox-containers-background-image-attachment-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Style&#62; .containerVBox { [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set a background image and change its attachment to scrolling or fixed for a Flex VBox container by setting the <code>backgroundImage</code> and <code>backgroundAttachment</code> styles.</p>
<p>Full code after the jump.</p>
<p><span id="more-417"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/VBox_backgroundAttachment_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/01/05/changing-a-vbox-containers-background-image-attachment-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        .containerVBox {
            backgroundColor: white;
            borderThickness: 1;
            borderColor: black;
            borderStyle: solid;
            paddingLeft: 5;
            paddingRight: 5;
            paddingTop: 5;
            paddingBottom: 5;
        }
    &lt;/mx:Style&gt;

    &lt;mx:String id="lorem" source="lorem.txt" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="backgroundAttachment:"&gt;
                &lt;mx:ComboBox id="comboBox"&gt;
                    &lt;mx:dataProvider&gt;
                        &lt;mx:Array&gt;
                            &lt;mx:Object label="scroll" /&gt;
                            &lt;mx:Object label="fixed" /&gt;
                        &lt;/mx:Array&gt;
                    &lt;/mx:dataProvider&gt;
                &lt;/mx:ComboBox&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:VBox styleName="containerVBox"&gt;
        &lt;mx:VBox id="vBox"
                backgroundImage="@Embed('Fx.png')"
                backgroundAttachment="{comboBox.selectedItem.label}"
                width="500"
                height="250"&gt;
            &lt;mx:Text width="100%" text="{lorem}" /&gt;
        &lt;/mx:VBox&gt;
    &lt;/mx:VBox&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/VBox_backgroundAttachment_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/VBox_backgroundAttachment_test/bin/main.html" width="100%" height="350"></iframe></p>
<p>If you want to set the <code>backgroundImage</code> and <code>backgroundAttachment</code> styles using an external .CSS file or &lt;mx:Style /&gt; block, you can use code similar to the following snippet:</p>
<pre class="code">
&lt;mx:Style&gt;
    VBox {
        backgroundImage: Embed("Fx.png");
        backgroundAttachment: fixed;
    }
&lt;/mx:Style&gt;
</pre>
<p>Or, if you want to set the <code>backgroundImage</code> and <code>backgroundAttachment</code> styles using ActionScript, you can use code similar to the following snippet:</p>
<pre class="code">
&lt;mx:Script&gt;
    &lt;![CDATA[
        private function vBox_initialize():void {
            /* Dynamically load image at runtime. */
            vBox.setStyle("backgroundImage", "Fx.png");
            vBox.setStyle("backgroundAttachment", "fixed");
        }
    ]]&gt;
&lt;/mx:Script&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Changing a VBox container\&#039;s background image attachment in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/01/05/changing-a-vbox-containers-background-image-attachment-in-flex/',contentID: 'post-417',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'backgroundAttachment,backgroundImage',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/01/05/changing-a-vbox-containers-background-image-attachment-in-flex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

