header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Jacob
Points:0
Posts:0
Answered

8/12/2010 10:49:30 PM

Title: BGImage


How to set background image for a windowed application without placing a image control.



1
Veer
Points: 480
Posts:0
8/12/2010 11:31:51 PM



Hi Jacob,

Check below code may solve your problem



<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
		creationComplete="onCreationComplete(event)" height="800" width="800" >
	
	 <mx:Script> 
        <![CDATA[ 
            import mx.events.FlexEvent; 
            
            private var bgLoader : Loader; 
            private var bgBitmapData : BitmapData; 
            private var bgImagePath:String = "Tulips.jpg"; // set your require background image path 
            
            private function onCreationComplete(event:FlexEvent):void 
            { 
                bgLoader = new Loader (); 
                bgLoader.contentLoaderInfo.addEventListener (Event.COMPLETE, bgLoadingComplete, false, 0, true); 
                bgLoader.load (new URLRequest (bgImagePath)); 
            } 
            private function bgLoadingComplete (event:Event):void 
            { 
                bgBitmapData = new BitmapData (bgLoader.width, bgLoader.height); 
                bgBitmapData.draw ( bgLoader ); 

                bgCanvas.graphics.beginBitmapFill (bgBitmapData); 
                bgCanvas.graphics.drawRect (0, 0, stage.stageWidth, stage.stageHeight); 
                bgCanvas.graphics.endFill (); 
            } 
        
        ]]> 
    </mx:Script> 
	
	<mx:Canvas id="bgCanvas" height="100%" width="100%" />
	
</mx:WindowedApplication>

let me know if you face any problem in this code.. Regards, Virat Patel

2
gourav
Points: 540
Posts:0
Accepted Answer
8/14/2010 4:10:31 AM



Hii,
First of all solution for window and web app is same , and yes you can a background image without using image control in flex.

<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
backgroundImage="assets/myimage.jpg"
height="800" width="800" >

// your code


</mx:WindowedApplication>


backgroundImage="assets/myimage.jpg" will set as a background Image.


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 6+0 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions