View Full Version : Changing images in flash.
kguerrero
01-07-2006, 02:35 PM
Hi,
I have developed a flash file which transitions through a series of 30 photos.
I created symbols for each of these photos so that I could tween the alpha effect.
What I would like to do is change the bitmaps these symbols refer to so that I can easily use different photos (without using flash and changing the symbol definition manually).
I am envisioning a series of folders where bitmaps are named in accordance with a specific convention. The swf file may be located in that folder, any of the photos located in the folder are used for the swf show.
One folder may contain 30 photos of Cats, a different folder may contain 30 photos of dogs. When I launch the swf in the cats folder the swf transitions through the photos of Cats. When I launch the swf inthe dogs folder the swf transitions through the series of dog photos. I never once go into flash to change these photos manually.
Or, if you have a better suggestion where I can get the same effect, please let me know.
Thanks
Hi,
You can dynamically load images into Flash at runtime. It can be done to a level or a movieclip. I tend to prefer movieclips because it allows you control over the movieclip holder properties that will affect the imported image....
_root.mcHolder.loadMovie("someFile.jpg");
You have the option of using a standard naming convention.......ie...
photo1.jpg,photo2.jpg....etc.....
You can put images into an array which makes it easy to update....
myImages=[photo1,photo2,photo3];
You can then use the array to load the appropriate image .....
_root.holderMC.loadMovie(myImages[0]);
This would allow you to update the image list array externally also.
Hope it helps
NTD
kguerrero
01-14-2006, 10:40 PM
I have converted my symbols and to movie clip and used the loadMovie actions. This works very well. Except ....
I have 24 layers each layers each layer is unique for the images I want to display. Example: Image 1. the action scripting is placed on the first "occupied" keyframe of each layer the action scripting is: loadMovie("iq image x.jpg","Image x"); Where x is the same number between 1 and 24.
As I said this works very well, I can place my swf file in any folder with 24 jpegs which follow the naming convention "iq image x". When I execute the swf file it will cycle through all the images in the folder.
What I am wondering is there a way to do this where the swf is not in the folder with the images. I have tried to specify the folder location in the action scripting example: loadMovie("C:\Documents and Settings\Kip\My Documents\Art 1\iq image 24.jpg","Image 24"); I have also tried loadMovie("file:\\\C:\Documents and Settings\Kip\My Documents\Art 1\iq image 1.jpg","Image 1");
Thanks
Hi,
When working with online files, you can define a file path to a folder and store it in a variable to be used later......
filePath="http://somesite.com/images/"
You can now use that file path variable to load the chosen content.....
_root.someMC.loadMovie(filePath+"someImage.jpg")
The .swf file does not need to reside inside the same folder as the content as long as an absolute url to the content is defined.
Now you would think loading a local file would work in the same manner. It doesn't. The problem is with the backslash character. The backslash character is a reserved character in Flash and is used as an escape......
trace("\")
outputs...
"String literal was not properly terminated"
However....
trace("\\")
outputs...
\
Extend it to a file path.....
trace("C:\someFolder\someImage.jpg")
outputs...
C:\omeFolder\omeImage.jpg
This obviously wont work for loading the image as the first letter after each backslash is escaped.
Solution....
trace("C:\\someFolder\\someImage.jpg")
outputs...
C:\someFolder\someImage.jpg
Escaping each backslash makes the correct filepath readable to flash.
Regards
NTD
kuldip
09-10-2007, 10:41 AM
hi i want image changing script in flash without using fla file can you halp me.
Mashka
09-10-2007, 12:52 PM
hi i want image changing script in flash without using fla file can you halp me.
Sorry, I don't know :(
Hi,
There are several approaches to this. You can use a text file in each folder that holds the list of names of the images in the particular folder. The text file could be loaded into a loadVars object and an array and the images used from the array to load into movieclip holders. Then it would simply be a matter of changing the path to the folder and textfile that you want to display in the image gallery.
Another approach takes a bit more programing but is much more advanced and efficient. You can use a bit of PHP to return any file contents in a folder to an XML object in Flash. Then, there is no need for a text file or loadVars object. The PHP script simply populates an array with the extension you choose. It will work with any file extension. However, if your not intermediate to advanced in Actionscript with a basic understanding of PHP, this will be hard to follow so I wont elaborate unless requested to. I've been planning on writing a tutorial on this as I have only seen a couple of people that understand the process and it is quite useful.
The final option is a full fledged content management system. This would allow for any content to be altered dynamically from an admin movie without ever needing to touch the main .fla file. Once again, this takes a good understanding of AS. I have written a tutorial to help understand the process but it is rather lengthy and covers several topics needed in such a project. The flat textfile version has a couple of bugs that I never attended to because the XML version of the CMS works flawlessly. Here is a thread with a link to the CMS tutorial...
http://www.flashadvisor.com/forum/save-xml-t2621.html?p=6668#post6668
hope it helps
NTD
Mashka
09-11-2007, 09:16 AM
Hello, very usefull information!!!!!!!
Thanks:)
Powered by vBulletin™ Version 4.1.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.