Problem in Loading Multiple image in Single Sprite/MovieClip
Hi All,
I am having a killing problem in loading multiple images in single movie clip/sprite using a separate class.
Here is the ImageLoader.as class
package com.project.utils{
import com.project.*;
import com.project.utils.*;
import flash.events.EventDispatcher;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.Loader;
import flash.events.IOErrorEvent;
import flash.net.URLLoader;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.display.Bitmap;
public class ImageLoader extends EventDispatcher {
public var imgloader:Loader;
public var imgMc:MovieClip;
public var imgObject:Object;
public var loaded:Number;
public function ImageLoader():void {
imgMc = new MovieClip();
imgObject = new Object();
imgloader = new Loader();
public function loadImage(imgHolder:MovieClip, imgObj:Object):void {
imgMc = new MovieClip();
imgObject = new Object();
imgloader = new Loader();
imgMc = imgHolder;
imgObject = imgObj;
imgloader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImgLoad);
imgloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onImgLoadProgress);
imgloader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onImageLoadFailed);
imgloader.load(new URLRequest(imgObj.FilePath));
private function onImgLoad(Evt:Event):void {
var image:Bitmap = Bitmap(Evt.target.content);
try {
imgMc.removeChildAt(0);
} catch (error:Error) {
imgMc.addChild(image);
try {
if (imgObject.URL != undefined) {
imgMc.buttonMode = true;
imgMc.removeEventListener(MouseEvent.CLICK, onImageClicked);
imgMc.addEventListener(MouseEvent.CLICK, onImageClicked);
} catch (err:Error) {
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD"));
private function onImageClicked(evt:MouseEvent):void {
trace("Image Attrs:"+imgObject.URL +" Target "+imgObject.Target);
private function onImgLoadProgress(Evt:ProgressEvent):void {
if (Evt.bytesLoaded>0) {
loaded = Math.floor((Evt.bytesLoaded*100)/Evt.bytesTotal);
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_PROC",loaded));
private function onImageLoadFailed(Evt:IOErrorEvent):void {
trace("Image Loading Failed");
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_FAIL"));
Here I am loading some images using the above class in a for loop, like
for (var i=0; i < 3; i++) {
//imgLoader=new ImageLoader;
imgLoader.addEventListener("CustomEvent.ON_IMGE_LOAD",onImageLoad);
var target:MovieClip=videolist_mc["list" + mcCount + "_mc"];
target.list_mc.visible=false;
var imgObj:Object=new Object;
imgObj.FilePath=list[i].Thumbnail;
imgObj.Url=list[i].Url;
imgObj.Target=list[i].Target;
target.list_mc.urlObj=new Object ;
target.list_mc.urlObj=imgObj;
imgLoader.loadImage(target.list_mc.imgholder_mc,imgObj);
target.list_mc.lable_txt.htmlText="<b>" + list[i].Label + "</b>";
target.list_mc.imgholder_mc.buttonMode=true;
target.list_mc.imgholder_mc.addEventListener(MouseEvent.CLICK,onItemPressed);
mcCount++;
In this case, the ImageLoader.as works only on the last movie clip from the for loop. For example, if i am trying to load three image in three movie clips namely img_mc1,img_mc2 and img_mc3 using the for loop and ImageLoader.as, I am getting the image loaded in the third movie clip only img_mc.
See at the same time, If i uncomment onething in the for loop that is
//imgLoader=new ImageLoader;
its working like a charm. But I know creating class objects in a for loop is not a good idea and also its causes some other problems in my application.
So, help to get rid out of this problem.
Thanks
-Varun
package com.project.utils{
import com.project.*;
import com.project.utils.*;
import flash.events.EventDispatcher;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.Loader;
import flash.events.IOErrorEvent;
import flash.net.URLLoader;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.display.Bitmap;
public class ImageLoader extends EventDispatcher {
public var imgloader:Loader;
public var imgMc:MovieClip;
public var imgObject:Object;
public var loaded:Number;
public function ImageLoader():void {
// better add you movieclip to the stage if you want to view anything added to it.
imgMc = new MovieClip();
imgObject = new Object();
imgloader = new Loader();
public function loadImage(filepath:String):void {
imgloader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImgLoad);
imgloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onImgLoadPr ogress);
imgloader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onImageLoadF ailed);
imgloader.load(new URLRequest(filepath));
private function onImgLoad(Evt:Event):void {
var image:Bitmap = Bitmap(Evt.target.content);
try {
imgMc.removeChildAt(0);
} catch (error:Error) {
imgMc.addChild(image);
try {
if (imgObject.URL != undefined) {
imgMc.buttonMode = true;
imgMc.removeEventListener(MouseEvent.CLICK, onImageClicked);
imgMc.addEventListener(MouseEvent.CLICK, onImageClicked);
} catch (err:Error) {
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD"));
private function onImageClicked(evt:MouseEvent):void {
trace("Image Attrs:"+imgObject.URL +" Target "+imgObject.Target);
private function onImgLoadProgress(Evt:ProgressEvent):void {
if (Evt.bytesLoaded>0) {
loaded = Math.floor((Evt.bytesLoaded*100)/Evt.bytesTotal);
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_PROC",loaded));
private function onImageLoadFailed(Evt:IOErrorEvent):void {
trace("Image Loading Failed");
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_FAIL"));
Here I am loading some images using the above class in a for loop, like
for (var i=0; i < 3; i++) {
var imgLoader:ImageLoader=new ImageLoader();
imgLoader.addEventListener("CustomEvent.ON_IMGE_LOAD",onImageLoad);
var target:MovieClip=videolist_mc["list" + mcCount + "_mc"];
target.list_mc.visible=false;
var imgObj:Object=new Object;
imgObj.FilePath=list[i].Thumbnail;
imgObj.Url=list[i].Url;
imgObj.Target=list[i].Target;
target.list_mc.urlObj=new Object ;
target.list_mc.urlObj=imgObj;
imgLoader.loadImage(pass the image file's path/name);
target.list_mc.lable_txt.htmlText="<b>" + list[i].Label + "</b>";
target.list_mc.imgholder_mc.buttonMode=true;
target.list_mc.imgholder_mc.addEventListener(MouseEvent.CLICK,onItemPressed);
mcCount++;
Similar Messages
-
Loading multiple images in IE...
Hi,
I encountered a very strange problem (probably bug) while
loading multiple images from IE. Flash is very simple (code is
stripped version of match larger program) it contains simple for
loop that loads image 20 times, and COMPLETE handler that position
image.
Running application from Flash IDE is ok, but if user run
flash embeded into html from IE (IDE auto generated html) and
interrupt loading (closes IE tab (not whole IE, just tab)) next
load of same html stop working. What is event more strange, is that
image url entered in addres field of IE will not work?!?!
To conclude, to reproduce this behavior: run html from IE and
close tab in middle of loading process (after few images loaded).
Running html again will not work (or typing image url into
address). NOTE that tab must be closed (not whole IE). Closing IE
and running html again will work normaly.
Is there any idea how to correct this? Note that I used
different image links, and any of them have same behavior, so i
excluded url as error.
P.S. I use IE 7 under the Vista, but IE 7 with XP also have
same behavior.
ThanksIf you mean that image service have simultaneous download
limit, it does not. We have number of tile-generating services, and
also prerendered images, and on every system we have same issue.
Also, any flash-based map that load tiles are prone for this
error (e.g. yahoo maps, flashearth even google flash maps).
P.S. On Firefox it works ok. -
Help with loading multiple images via LoadVars
Hello everybody.
I need a hand loading multiple images using the LoadVars
method with a text file. I can get it to load 1 image but not
anymore than that. I am aware of other methods like using
components but I am looking for a method where I can access and
change all data from 1 text file (there will be text variable text
within the file aswell to, but I am more concerned with the images
at the moment).
Anyway on to the issue. I have created a much simple .fla
file that outlines my problem.
The movie contains 3 layers:
- top layer contains AS
- middle layer contains an empty movie clip with the
instance name of mcImage1
- bottom layer contains an empy movie clip with the instance
name of mcImage2
The AS layer contains the following code:
imagedata = new LoadVars()
imagedata.load("data.txt")
imagedata.onLoad = function(ok){
if(ok){
mcImage1.loadMovie(this.Image1)
mcImage2.loadMovie(this.Image2)
} else trace("Problem Loading")
In the same folder of my .swf file I have a text file called
data.txt which contains the following
&Image1=image1.gif
&Image2=image2.gif
Also in the same folder of my .swf file I have two images
image1.gif and image2.gif.
When I run the flash the image2.gif is imported correctly.
image1.gif does not appear.
You can download my source files and all images here
http://www.myrealpage.com/projects/var_test/var_test.zip
Any help that can be shed on this problem is much
appreciated.
Thanks
MattGlad to help. It is just that I see so many folks who have
two different parts of a problem smushed together – each
problem isn't so hard on its own, but together they are difficult
to wrap your head around. Always try and break down each step of
the problem and it will help you in the end.
That being said, I'm not quite so sure on this next problem.
I don't do so much timeline stuff along with the Actionscript. I
can get tricky. So this I don't quite have as much of clear mental
picture of what you are describing. But here are some questions
that I would ask – either of myself if I was doing it or of
you.
Is there a stop() on frame one to wait for the
LoadVars.onLoad? Does the onLoad then say to play?
If not, what happens if we get to Frame 10 before the
LoadVars has even finished? That could be a problem.
Remember that the LoadVars object is an actual object that
will exist until it is deleted or removed in various ways. You can
access it at any time after it is loaded. The onLoad event handler
is just that thing you want to happen immediately after it is
loaded.
So my design would probably be.
LoadVars on Frame 1.
Where I am stopped.
In the onLoad handler load the first image and tell the
timeline to play
On frame 10, the LoadVars object will still exist (unless
you've deleted it)
Get the variable out of the LoadVars and load the image.
If you want to check this. Put a stop() in frame 10 and run
it in the testing environment. When it gets to that frame, go to
the debug menu and List Variables. You should see that your
LoadVars object is still there.
Does that answer your question or am I totally missing the
point? -
Load Multiple Images in Crystal Report using Paths
Hi Guys,
I am currently in need of developing a new requirement for our company's client. We have to load multiple images using just link in Crystal Report. Let's say that the images are stored in a folder (e.g., C:\Datafolder\Images\) and i have to fetch two images to show in crystal report (say, C:\Datafolder\Images\imageval1 and C:\Datafolder\Images\imageval2). These are actually dynamically created and therefore the number of images are not known and so i have to iterate through the list of image links.
Is it possible using merely crystal report and how?. If not, can I do it using Crystal Report SDK?. Any help will be appreciated. Please take note that we're also using C# in developing our software applications.
Thanks and best regards.
---CHITO--There are also a number of KBAs:
1296803 - How to add an image to a report using the Crystal Reports .NET inproc RAS SDK
1199408 - How to load an image from disk into a dataset using CSharp (C#) in Visual Studio .NET
Other related KBAs:
1216239 - How to access a Crystal Report "Preview Picture" using the CR .NET or RAS .NET SDK?
1373770 - How can I add a picture to a Crystal Reports subreport using the RAS .NET SDK?
1320507 - How to change images dynamically in Crystal Reports based on parameter selection?
And more. Please do use the search box in the top right corner. Simple search terms are best. E.g: 'crystal image net' or 'crystal image format formula', etc.
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow us on Twitter -
Load multiple images from directory?
What is the best way to use CF to load multiple images from a
server directory please? I have CF calling a stored procedure that
returns an array of file names. I am using a Flex front end, and
wonder if I should just pass the file name array to Flex and let it
loop through and load each image into an array. Or is it possible
from within my CFC to use the file name array to get CF to grab the
images and then pass that image array back to Flex? If so, is there
any advantage to either approach? TIA,
Mic.You don't want to pass the binaries to Flex, you should just
give Flex the image names and load them via HTTP. -
Problem Rating / Deleting Multiple Images
I have a Problem Rating / Deleting Multiple Images at the same time. For the last 2 weeks I have been unable to select a group of images and rate them all - I have to select images indiviually for the rating to work. This also is the case when trying to delete images.
Anyone know if this is a bug?Hit 'S' which toggles 'Primary Only' mode - this swaps between applying ratings,deletions to multiple images or just the one with the thicker selection border.
Ian -
When iam loading multiple datatargets with single datasource request failed
when iam loading multiple datatargets with single datasource request failed
i want to delete the bad request at a time in all datatargetsHi Neeraj,
The only thing you can do is go in to theMonitor screen of that IP and select the datatargets from the Monitor screen.In the next screen you can see all the targets included in the IP at the top.But the only bad thing is you have to manually delete the Bad request only from each target.
Regards
Sandeep -
Load Multiple Images using link in Crystal Report
Hi Guys,
I am currently in need of developing a new requirement for our company's client. We have to load multiple images using just link in Crystal Report. Let's say that the images are stored in a folder (e.g., C:\Datafolder\Images\) and i have to fetch two images to show in crystal report (say, C:\Datafolder\Images\imageval1 and C:\Datafolder\Images\imageval2). These are actually dynamically created and therefore the number of images are not known and so i have to iterate through the list of image links.
Is it possible using merely crystal report and how?. Please take note that we're also using C# in developing our software applications.
Thanks and best regards.
---CHITO--Hi Chito,
You cannot load multiple images dynamically. Using the 'graphic location' formula for the OLE Object, you can only point to a location that can load one image.
For the second image, you'll need to manually insert another OLE Object and point the formula to the next image's location.
You can try posting to the SAP Crystal Reports, version for Visual Studio space to find out whether this can be done using CR SDK.
-Abhilash -
Anyone got a script to import multiple placed images into CS4? or is this possible in CS5?
and can we output multiple layers into a single PDF in illustrator? Or multiple layers into single JPEGS from illustrator with one command instead of individually saving out each page... would be a huge time saver for me.
Currently I output each completed layer individually and then right click those outputted jpegs in their output folder and choose "combine supported files into acrobat..." to make a single acrobat file..
I`d also like to be able to CTRL click multiple layers and go save as... only those layers get saved out...
And so adding something in the Save for PDF output dialogue box to save layers to multiple pages would be a helpful time saver..In CS 4 and CS 5 you can drag and drop fro m the finder or the Bridge, and I guess any other similar type viewer, multiple number of image files to a document. You can configure the bridge in such a way as to allow you to see the Bridge and your document at the same time for this very purpose.
If you just drag and drop the files are linked if you drag while holding the shift key then the files will be embedded.
ID and PS CS 5 have a minibridge which works the sam way but is an actually panel and will stay in the front.
I separate the images but they import one on top of another. -
Printing multiple images on single page
Can anyone explain how to print multiple images on the same page such as 4-4x6 photos? Or the same image more than once on a page - similar to the N-up option in iPhoto? Anything new and helpfull for printing in 1.5? Thanks.
No, it isn't what we're looking for.
Let's take the example of a professional portrait photographer (me? ) trying to set up a home-lab with a wide format, roll printer.
I get an order for, say, 2 4x5 of image 1, 2 4x5 of image 2, 4 5x7 of image 3. I have 10" paper loaded in my roll.
What I would want to do is gang the prints onto 3 "units" - the 4 4x5 on one 8"x10" unit, and 2 5x7 on each 7"x10" unit.
Since my clients ordered specific sizes, I need to make sure I get the prints sized exactly right (contact sheet tool doesn't let me do this) and since printing is pricey, I want to make sure to waste as little paper/ink as possible. I also don't want to get stuck doing a lot of trimming.
So, in lightroom, photoshop, imagebuddy, portraits-n-prints etc, I would just ask the app to output the package for me. In Aperture, I'm stuck. I can't use the book tool because it uses a (moronically) fixed page-size. I can't use the contact sheet tool because it doesn't let me specify image size/aspect ratio. I can't use the "standard" print tool because it only prints one image per page.
This is a glaring omission, and a slap in the face to the professionals that Aperture claims to see as its target audience. -
hi again :)
i'm trying to load an image (EPS format) on a JPanel like i've done with GIF or JPG , those don't cause any problem, but when the image is an EPS one nothing is loaded how can i do this ?
Thanksis there any answer or suggestion please
thanks -
Loading multiple images dynamically
hi,
trying to load several images to timeline keyframes,
managed to load one, how to load several,
Here´s the code:
var imageLoader:Loader;
function loadImage(url:String):void {
imageLoader = new Loader();
imageLoader.load(new URLRequest(url));
imageLoader.contentLoaderInfo.addEventListener(Pro gressEvent.PROGRESS, imageLoading);
imageLoader.contentLoaderInfo.addEventListener(Eve nt.COMPLETE, imageLoaded);
loadImage("Images/pori1.jpg");
function imageLoaded(e:Event):void {
imageArea.addChild(imageLoader);
function imageLoading(e:rogressEvent):void {hi,
I appreciate if I would get some more advice on this.
I´m trying to load each image to a frame(instance/imageArea1,2,3...) and to be loaded when needed (using next- or previous -buttons).
Here´s my code so far:
stop();
var imageLoader:Loader;
var images:Array = new Array("Images/pic1.jpg","Images/pic2.jpg");
for(var i:uint = 0;i<images.length;i++){
var request:URLRequest = new URLRequest(images[i]);
var loader:Loader = new Loader();
loader.x = i * 100;
loader.load(request);
this.addChild(loader);
package KC {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class NextBtn extends MovieClip {
public function NextBtn():void {
buttonMode = true;
addEventListener(MouseEvent.MOUSE_DOWN, btnEvent);
function btnEvent(evt:MouseEvent):void {
MovieClip(parent).gotoAndStop(MovieClip(parent).currentFrame + 1);
package KC {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class PrevBtn extends MovieClip {
public function PrevBtn():void {
buttonMode = true;
addEventListener(MouseEvent.MOUSE_DOWN, btnEvent);
function btnEvent(evt:MouseEvent):void {
MovieClip(parent).gotoAndStop(MovieClip(parent).currentFrame - 1); -
Load multiple action in single script
HI
I want to load selective action in single window with radio buttons
When click this actions it will run
i want this in scriptHi c.pfaffenbichler
thanks for giving links for configurator
please tell me if theres is any possible convert script to plugin
OR
how to create plugins and how to place under filter menu
thanks -
Windows 7 Multiple image on single HDD
I have 15 new lenovo laptop with same configuration and I need two set of images , one is with Win7 Enterprises with office 2010 and Win7 Entr with office 2013, since I have same configuration I captured two different images using windows Backup utility
and saved into external HDD and images named as follows
WindowsImageBackup-Office2k13
WindowsImageBackup-Office2k10
I have two set of images , one is with win-7 with office 2010 and second one is win7 with office 2013. After capturing the image I have renamed as Win7-Off2k13 and Win7-Off2k10 but when I boot from repair disk and navigate the external USB ( images are saved
in external USB drive ) it not showing any images. since its not showing any images I renamed image as default "WindowsImageBackup" after that it started recognizing image and able to image successfully . My question as follows
1) Can we have multiple images on one disk ( same computer image with two different date )
2) Can we rename backup image file ?
3) If i capture a image of one laptop , can this image be used in different laptop with same configuration and model ? Do I need to do sysprep if im gonna restore this image in different machine with same configuration?
ShakkeerIf you have an existing system image for a computer and are creating a new one for the same computer, the new system image will overwrite
the existing one. If you want to keep the existing system image, you can copy it to a different location before creating the new system image
Got from MS references.
Arnav Sharma | http://arnavsharma.net/ Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading
the thread. -
Loading multiple images in applet
I am trying to create an applet that displays 8 images in a grid and up until now I have had no problems loading single images into the applet but I am having difficulty more than one. I thought I could just create multiple lines of the getImage method. It keeps telling me that an identifier is expected. I'm quite new to this so don't mock me.
import java.applet.*;
import java.awt.*;
import javax.swing.*;
public class clown extends Applet {
Image[] cln=new Image[8];
cln[0]=getImage(getDocumentBase(), "clown2.gif");
cln[1]=getImage(getDocumentBase(), "clown3.gif");
cln[2]=getImage(getDocumentBase(), "clown4.gif");
cln[3]=getImage(getDocumentBase(), "clown5.gif");
cln[4]=getImage(getDocumentBase(), "clown6.gif");
cln[5]=getImage(getDocumentBase(), "clown7.gif");
cln[6]=getImage(getDocumentBase(), "clown8.gif");
cln[7]=getImage(getDocumentBase(), "clown9.gif");
public void paint(Graphics g){
g.drawImage(cln[0], 0, 0, 0, 0, this);
g.drawImage(cln[0], 50, 10, 0, 0, this);
g.drawImage(cln[0], 100, 10, 0, 0, this);
g.drawImage(cln[0], 150, 10, 0, 0, this);
g.drawImage(cln[0], 200, 10, 0, 0, this);
g.drawImage(cln[0], 250, 10, 0, 0, this);
g.drawImage(cln[0], 300, 10, 0, 0, this);
g.drawImage(cln[0], 350, 10, 0, 0, this);
}Ive just noticed a mistake but that still doesnt resolve the problem it should read:
import java.applet.*;
import java.awt.*;
import javax.swing.*;
public class clown extends Applet {
Image[] cln=new Image[8];
cln[0]=getImage(getDocumentBase(), "clown2.gif");
cln[1]=getImage(getDocumentBase(), "clown3.gif");
cln[2]=getImage(getDocumentBase(), "clown4.gif");
cln[3]=getImage(getDocumentBase(), "clown5.gif");
cln[4]=getImage(getDocumentBase(), "clown6.gif");
cln[5]=getImage(getDocumentBase(), "clown7.gif");
cln[6]=getImage(getDocumentBase(), "clown8.gif");
cln[7]=getImage(getDocumentBase(), "clown9.gif");
public void paint(Graphics g){
g.drawImage(cln[0], 0, 0, 0, 0, this);
g.drawImage(cln[1], 50, 10, 0, 0, this);
g.drawImage(cln[2], 100, 10, 0, 0, this);
g.drawImage(cln[3], 150, 10, 0, 0, this);
g.drawImage(cln[4], 200, 10, 0, 0, this);
g.drawImage(cln[5], 250, 10, 0, 0, this);
g.drawImage(cln[6], 300, 10, 0, 0, this);
g.drawImage(cln[7], 350, 10, 0, 0, this);
Maybe you are looking for
-
Here's the log of my Macbook Pro, as I'm using a chinese version, so log can only appear as below. Reason I try to use Disk Utility's Repair is because the finder got not respond so ofter, it happen after my unscuessful power loss issues happen at ho
-
Iphone not showing up in itunes
I have just installed windows 8 developer preview on my system but now my iPHONE 4 is not showing up in itunes , It works in b/w sometime,, ny idea ?
-
Older G5 airport extreme installation
I have an older G5 power mac that did not have a wireless card. i bought an airport extreme card and it does not appear to want to go into the slot. Is it possible to install an airport extreme card or do I have to take it in and have it upgraded som
-
Organisational Structure Business Area
Dear All I am the stage of organizational structure finalization for one of the client in US. I need some suggest how to convince the client as he not ready to PCA. Scenario are. 1. One company code 2. Four Plant in US. 3. 6 Products 4.
-
I am writting a Crystal application, where users could run adhoc reports and schedule them. My AdHoc options works fine, but I am having some issues with the Scheduling portion. In my project, to read the parameters, I am using CrystalReportsPartsVie