Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-31-2008, 10:44 PM   PM User | #1
jasonc310771
Regular Coder

 
Join Date: Mar 2006
Posts: 478
Thanks: 3
Thanked 0 Times in 0 Posts
jasonc310771 can only hope to improve
flash where i can change images without having to redo flash file

I have a flash file which has 3 images fly in to the page, and wish to know if it is possible to create a file that allows me to change these images for different ones instead of having to create a new flash file each time.
jasonc310771 is offline   Reply With Quote
Old 10-31-2008, 10:50 PM   PM User | #2
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
You could have them load via XML, and then change the XML file each time with a new link to the images.

There is a thread in my signature that shows one method of achieving this. There are also tutorials in the sticky in the Flash forum.

Try something out, and if you have questions come on back!
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 10-31-2008, 11:47 PM   PM User | #3
jasonc310771
Regular Coder

 
Join Date: Mar 2006
Posts: 478
Thanks: 3
Thanked 0 Times in 0 Posts
jasonc310771 can only hope to improve
hey thanks

just looked and found this tutorial... http://www.actionscript.org/resource...XML/Page2.html

but it only allows one image and having it static, my images flys in to the page from three different places and come to rest after a few summersalts.

do you have a tutorial for multiple images that move around the movie file?
jasonc310771 is offline   Reply With Quote
Old 11-01-2008, 06:06 AM   PM User | #4
itsallkizza
Senior Coder

 
Join Date: Oct 2008
Location: Long Beach
Posts: 1,196
Thanks: 36
Thanked 164 Times in 164 Posts
itsallkizza will become famous soon enough
You can set up an xml file something like:
my_images.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<images>
	<image src="images/img0.jpg">Image One</image>
	<image src="images/img1.jpg">Image Two</image>
	<image src="images/img2.jpg">Image Three</image>
</images>
Load that into Flash using the method you learned in the tutorial(s) you read:
Code:
var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success:Boolean):Void
	{
	if (success)
		{
		//do your stuff
		}
	else //catch error loading xml
	}
my_xml.load("my_images.xml");
Inside the onLoad function is where you want to start parsing through the xml nodes and grabbing the src of each:
Code:
var my_imgs_src:Array = [];
for (var i:Number=0;i<my_xml.firstChild.childNodes.length;i++) my_imgs_src.push(my_xml.firstChild.childNodes[i].attributes["src"];
Then load your images into empty movie clips and animate them however you want:
Code:
var mclstnr:Object = new Object();
var mcldr:MovieClipLoader = new MovieClipLoader();
mcldr.addListener(mclstnr);
mclstnr.onLoadInit = function(target_mc:MovieClip):Void
	{
	//use ._x and ._y to place the loaded picture on the screen
	//then launch your animation
	//if you want them to all start at exactly the same time, then make a counter,
	//and each onLoadInit check for counter completion, if complete then launch animation
	}
for (var i:Number=0;i<my_imgs_src.length;i++) mcldr.loadClip(my_imgs_src[i],_root.createEmptyMovieClip("image"+i,_root.getNextHighestDepth()));

Last edited by itsallkizza; 11-01-2008 at 06:09 AM.. Reason: spelling
itsallkizza is offline   Reply With Quote
Old 11-01-2008, 06:03 PM   PM User | #5
-Fabez-
New Coder

 
Join Date: Oct 2008
Location: Earth
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
-Fabez- is an unknown quantity at this point
You could use the LoadMovie function, much easier than XML and replace the images with the new ones when you want to change them. An example is below.

Code:
PictureHolder_mc.LoadMovie("Picture1.jpg")
__________________
I can code in, C++, C, Python, Html, Php, Javascript, Css, Visual Basic, MySql, ActionScript 2, ActionScript 3 and Mythbuster :)
<Mythbusters> Am i missing an eyebrow ? </Mythbusters>

Need a hand with coding or devoloping software ? Just ask ;) Or visit the Coding Group
-Fabez- is offline   Reply With Quote
Old 11-01-2008, 06:45 PM   PM User | #6
jasonc310771
Regular Coder

 
Join Date: Mar 2006
Posts: 478
Thanks: 3
Thanked 0 Times in 0 Posts
jasonc310771 can only hope to improve
Quote:
Originally Posted by -Fabez- View Post
You could use the LoadMovie function, much easier than XML and replace the images with the new ones when you want to change them. An example is below.

Code:
PictureHolder_mc.LoadMovie("Picture1.jpg")
this i like the sound of, one line?!

or is there more to it, where would this line be placed?
jasonc310771 is offline   Reply With Quote
Old 11-01-2008, 07:18 PM   PM User | #7
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
You just place it in the root timeline, probably first frame.

So you do it 3 times for each movieClip

Code:
pic1.LoadMovie("Picture1.jpg");
pic2.LoadMovie("Picture2.jpg");
pic3.LoadMovie("Picture3.jpg");
And you make 3 blank movieClips named pic1, pic2, and pic3 (in the instance name of course). Then you animate them (they will be blank in the editor, but when you test it with the pictures it will place them in the movieClips) and all works!
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:39 PM.


Advertisement
Log in to turn off these ads.