• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 684
  • Last Modified:

Putting background in flash

From this previous question:
http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/Q_23118289.html
How do I put a background in? I can't just drag an image from my library, it blocks everything.

Thanks!
0
894359
Asked:
894359
1 Solution
 
RobOwner (Aidellio)Commented:
what about if you add a layer at the bottom of your timeline, select it and then drag in your image?
0
 
894359Author Commented:
I get the text showing but not the images fading in and out!
0
 
cforantCommented:
Put background image on a separate layer (Insert > Timeline > Layer) and drag the layer to the bottom of all layers.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
894359Author Commented:
I did that but still don't see the images fading in and out.
0
 
894359Author Commented:
Here's the as involved.
package{
	import caurina.transitions.Tweener;
	
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.net.URLLoader;
	import flash.net.URLLoaderDataFormat;
	import flash.net.URLRequest;
	import flash.net.URLVariables;
	import flash.text.Font;
	import flash.text.TextField;
	import flash.text.TextFormat;
 
	public class SlideShowText extends Sprite{
		private var images:XMLList;
		private var texts:XMLList;
		private var delay:Number = 0;
		private var currentIndex:int = 0;
		private var loader:Loader;
		//private var text:TextField;
		private var xml:XML;
		private var uloader:URLLoader;
		
		public function SlideShowText(){
			uloader = new URLLoader();
			uloader.addEventListener(Event.COMPLETE,onComplete);
			//First we load the xml
			uloader.load(new URLRequest("images.xml"));
			//And set the loader for the images
			loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE,imageComplete);
			loader.addEventListener(IOErrorEvent.IO_ERROR,onError);
			loader.alpha = 0;
			//Text was created on stage
			text.alpha = 0;
			//Must embed fonts so it accepts alpha
			//Look at the library there is a font item there to, exported for actionscript
			text.embedFonts = true;
			//add the loader to stage in depth 0, below the text that was already there
			addChildAt(loader,0);
		}
		
		private function onComplete(e:Event):void{
			//On complete xml download
			xml = new XML(uloader.data as String);
			//fill properties with xmllists - like arrays
			images = xml..image;
			texts = xml..text;
			delay = Number(xml.@delay);
			//Then we can start the slideshow
			initSlideShow();
		}
		private function onError(e:IOErrorEvent):void{
			trace(e.text);
		}
		private function loadImage(index:int):void{
			var url:String = images[index].toString();
			loader.load(new URLRequest(url));
		}
		private function initSlideShow():void{
			//First step - load first image
			loadImage(currentIndex);
		}
		public function imageComplete(e:Event):void{
			//when download is complete
			text.text = texts[currentIndex];
			//set its size to stage size 200x200
			loader.width = stage.stageWidth;
			loader.height = stage.stageHeight;
			//then fadeIn image
			imageIn();
		}
		public function imageIn():void{
			//fades image in
			Tweener.addTween(loader,{alpha:1.0,time:1,onComplete:textIn});
			//after fadein complete: textIn
		}
		public function textIn():void{
			//fades text in
			Tweener.addTween(text,{alpha:1.0,time:1,onComplete:textOut});
			//fades text out
		}
		public function textOut():void{
			//fades text out but wait for the delay - 3000/1000 = 3 seconds
			Tweener.addTween(text,{alpha:0.0,time:1,delay:delay/1000,onComplete:imageOut});
			//imageOut
		}	
		public function imageOut():void{
			//fades image out
			Tweener.addTween(loader,{alpha:0.0,time:1,onComplete:nextImage});
			//nextImage
		}
		public function nextImage():void{
			//increase index
			currentIndex++;
			//if index greater than number of images, back to image 0
			if(currentIndex >= images.length())currentIndex = 0;
			//load next image based on the index
			loadImage(currentIndex);
		}		
	}
}

Open in new window

0
 
julianopolitoCommented:
The background should be put in the FLA document, in a layer below the text layer. Also you should change the line 42 in the .AS file for this:

addChildAt(loader,1);

This will add the image loaded below the text, but above your custom background. I'm sorry for taking so long to respond, I was not home for th weekend
0
 
894359Author Commented:
Thanks for the response! Much appreciated again! :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now