loading and unloading external SWF and display the jpg file

Posted on 2009-04-16
Last Modified: 2013-11-11
I have a window created by FlexBuilder/Actionscript 3. I am trying to play a SWF movie clip and after the movie done playing I want to display the jpg. I am new to Actionscript world, please provide codes how to do it. Some problems I am facing is - the SWF movie plays for ever (loop is default). That is why I have a timer object to stop after some seconds and load and display the jpg. The movie is stopping at given seconds but jpg is not displaying. here is the codes i have so far -
//Test Program



	import flash.display.*;


	import flash.geom.*;


	import flash.text.*;

	import flash.utils.*;



	public class ScriptTest extends Sprite{


		private static var name:String = "VirtualTest";

		private static var introMovieFileName:String = "INTRO.swf";

		private static var backgroundImage:String = "BACKGROUND.jpg";

		private static var timeframe:int = 10;//Play for this many seconds

		private static var timeIntroLast:int = 13500;

		private var loader:Loader;

		private var imageLoader:Loader;


		//private var instance:Object;



		public function ScriptTest(){


			//instance = this;


			var timer:Timer = new Timer(timeIntroLast);

			timer.addEventListener(TimerEvent.TIMER, onTimer);




			//Load Module.swf

			loader = new Loader();

			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoader_Complete);

			loader.load(new URLRequest(introMovieFileName));




		private function onLoader_Complete(e:Event):void{

			 = -375; = -150;



		private function onTimer(e:Event): void{






			//Load image and display

			imageLoader = new Loader();

			imageLoader.load(new URLRequest(backgroundImage));










Open in new window

Question by:openujs
    1 Comment
    LVL 11

    Accepted Solution


    A few things to try.   Change




    Second, place your timer code in the function

    That way it will only start counting after the clip is fully loaded.

    Third,  instead of removing the loader child, remove the loader from the display list:


    And, if you'll not need this movie again, then delete it after removing it by setting loader=null and letting the garbage collector sweep it away.

    Are you certain your background image is in the same directory as the swf?  Is the name correct?  Are you running in a case sensitive environment?


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    SCCM 2012 - Deploy Flash 16 6,782
    Firefox fullscreen video lags 4 143
    video live streaming 1 107
    Java and adobe flash updates 4 30
    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…
    Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
    The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
    The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

    745 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

    16 Experts available now in Live!

    Get 1:1 Help Now