Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    478
    Thanks
    3
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    478
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    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 07:09 AM. Reason: spelling

  • #5
    New Coder
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    Regular Coder
    Join Date
    Mar 2006
    Posts
    478
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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?

  • #7
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •