As3IsoLib: Loading Image and Adding to Sprite.

I'm using a library called 'As3IsoLib' in my isometric game to create sprites and other elements. Currently I add a sprite and load an image to be displayed for the sprite. Up until now I have not checked to see when the image has actually loaded as I just straight away add it. That's got me thus far but now I'm expericening 'security' errors in flash which apparently mean it's trying to add an image which hasn't yet fully loaded.
Since I was going to be loading lots of images I put such under a function entitled 'LoadImg'. This is passed a string that is the location of the image we wish to load.
var UnitSprite:IsoSprite;
UnitSprite.moveTo(0, 0, 0);
UnitSprite.sprites=[LoadImg('imgs/picture.png')];
DrawSprite(UnitSprite);
function LoadImg(Img:String):Loader
     var myLoader:Loader;
     myLoader=new Loader();
     myLoader.load(new URLRequest(Img));
     return myLoader;
But now I need to say when it's completed loading the image then return the loader which isn't possible. I can't add an event handler saying when the 'myLoader' has completed because then you have to supply a second function rendering me unable to use return. I also cannot pass it the sprite I wish to add the image to. I've read in AS2 you were able to pass additional arguments. Such would solve my problem via something along the lines of...
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, AddImg(SpriteToAddImgTo));
function AddImg(e:Event,Spr:IsoSprite)
    Spr.sprites = [e.target];
But I'm using AS3 so I cannot do such. I've read several times on the Internet that it is possible to pass addional arguments ( see http://sinfinity.pl/blog/2012/03/28/adding-parameters-to-event-listener-in-flex-air-as3/ )
but I cannot get it to work. How might I achieve this?

that may (or may not) be caused by trying to use the loader's content before loading is complete.  to remedy the problem, if it's caused by trying to use the loader's content before loading is complete use:
var UnitSprite:IsoSprite;
UnitSprite.moveTo(0, 0, 0);
     var myLoader:Loader;
LoadImg('imgs/picture.png');
function LoadImg(Img:String):void
myLoader=new Loader();
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, AddImg);   
myLoader.load(new URLRequest(Img));
function AddImg(e:Event)
Spr.sprites = [e.target];
UnitSprite.sprites=Bitmap(myLoader.content); 
DrawSprite(UnitSprite); }

Similar Messages

  • I was changing my desktop screen saver in system preferences screen protection.  Now it says it is "Loading Images" and won't stop.  The Colourful wheel goes around for ever and It does not stop. Can anyone help me?

    I was changing my desktop screen saver in system preferences>screen protection.  Now it says it is "Loading Images" and won't stop.  The Colourful wheel goes around for ever and It does not stop. Can anyone help me?

    Welcome to the Apple Support Communities
    I have seen a lot of cases like your issue, and it's easy to solve.
    First, open Disk Utility, select Macintosh HD in the sidebar and repair permissions. Sometimes, a permission can be damaged and it makes that an application doesn't work properly.
    If that doesn't work, open Finder, select Go menu > Go to Folder, type ~/Library/Prefereces, delete "com.apple.desktop.plist" and "com.apple.systempreferences.plist" and restart

  • After I click system preferences to change my screensaver, it will say loading images and the cursor will be loading. How do i fix this ?

    After I click system preferences to change my screensaver, it will say loading images and the cursor will be loading. How do i fix this to be able to change my screensaver and not have my computer do this?

    Try system preferences>desktop,click desktop tab. Click the Apple folders, iPhoto, or folders. Click the pic you want on the icon, it should put the pic as your wallpaper. You can change the picture if you change picture if you click it and the time.  Unless I don't understand your question.  ATB

  • Using Firefox to access facebook chat Button or online friiend chat button generates a Black screen with CANNOT LOAD IMAGES and no chat window opens.

    This does not happen in other browsers and it happens on a variety of computers I have access to and would seem to be a common problem but I can find no identical cases in my searches of
    Firefox , Facebook or windows help or Google search. My home machine is only a P2 with WINXPCORP but works fine and I have done all updates but still have this continuing problem every time I try to use Firefox
    to access Facebook chat but it does not happen with IE or chrome
    The response to clicking on chat button or friend chat is a black screen with small center square box with blue title bar that says
    '' VIEW IMAGE FULL SCREEN - (42) FACEBOOK X""
    center of box is ""! "" mark in yellow triangle and wording
    "" CANNOT LOAD IMAGES ''' OK
    clicking on OK returns to facebook page but no chat opens.
    Some times |VERY RARLEY if as the page loades you click on
    chat button with 1/2 second of it appearing chat will open.

    Hi,
    Please also see [https://support.mozilla.org/en-US/kb/Problems%20using%20Facebook%20in%20Firefox this.]

  • Why won't safari load images and connect to websites?

    We've had this problem intermittently for several months. When visiting SOME websites (though never the same ones twice) instead of loading images, it comes up with a blue question mark in a box. if we try to reload the page, it will do one of two things: it will either reload exactly the same, or, it will reload in a format that shows vertical written links - no images. it almost looks like programming language, but it's readable.
    also, when we go between links, we often get the message that "safari can't find the server". this is, again, erratic. If i try to go directly to the same website by typing in the address in the bar, i will get the connection. (so, if i go from youtube for example to try to connect to another website it won't work. but if i try to go directly to that website by just typing in the address myself, i can get it.) as i said, it doesn't always happen, but when it does it's a real pain!
    lately, i've had a new problem too, which seems to relate: when using hulu.com, it will not load the show saying it is unavailable and to clear my cache. I've done that... and it still won't reload. yet, when i go to google, and search hulu.com, and go to the website that way, i can get to the show page no problem. Or, i have to quit safari and then go back to hulu and, again, no problem.
    sometimes we can go for days without the problem, sometimes not.
    any ideas on how to help this problem would be MOST appreciated! thanks

    blue question mark in box
    Go to Safari > Preferences then select the Appearance tab. Make sure Display images when the page opens is selected.
    For server issues, try turning off the router for a few minutes, then restart it.
    Hulu requires the Flash plugin. Uninstall your current copy of Flash, then reinstall >  Troubleshoot Flash Player | Mac OS
    Try emptying the Safari cache more often.
    And reset Safari. From your Safari menu bar click Safari > Reset Safari. Select the top 5 boxes, click Reset.
    And how much free space on the startup disk?     Right or control click the MacintoshHD icon. Click Get Info. In the Get Info window you will see Capacity and Available. Make sure there's a minimum of 15% free disk space.
    Try Safari in another user account. Same problems there, then log back into your admin account, launch Disk Utility.  /Applications/Utilities
    Select the startup disk in the panel on the left then select the First Aid tab.
    Click: Verify Disk  (not Verify Disk Permissions). If the startup disk needs repairing, follow the instructions for Using Disk Utility to verify or repair disks

  • Load image and video dynamically...

    Hello. Can I make a "Browse..." button in a "Settings" slide (at the beginning of the presentation), to point my presentation to a certain photo (one photo) and video (one video) files from a HDD? I want to use those files in one of next slides... Thank You!

    I was able to create a file with 2 buttons that will upload image and video separatly and it works fine.
    But what I want is there is a 3rd button for submitting the selected files, right now the files are uploaded as soon they are selected and the browse window is closed..
    How do I get to upload the selected files only when the SUBMIT button is clicked. Please help.
    var imageTypes:FileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png");
    // Assign the document types filter
    var videoTypes:FileFilter = new FileFilter("Flash Movies (*.avi, *.flv, *.mov, *.swf)", "*.swf");
    // Add both filter types to an array
    var imgTypes:Array = new Array(imageTypes);
    var vdoTypes:Array = new Array(videoTypes);
    upload_image.addEventListener(MouseEvent.CLICK, browseImage);
    upload_vdo.addEventListener(MouseEvent.CLICK, browseVdo);
    var fileRefList:FileReferenceList = new FileReferenceList();
    function browseImage(event:MouseEvent):void {
        fileRefList.browse(imgTypes);
        fileRefList.addEventListener(Event.SELECT, selectHandler);
    function browseVdo(event:MouseEvent):void {
        fileRefList.browse(vdoTypes);
        fileRefList.addEventListener(Event.SELECT, selectHandler);
    function selectHandler(event:Event):void
        var request:URLRequest = new URLRequest("fileUploadScript.php");
        var file:FileReference;
        var files:FileReferenceList = FileReferenceList(event.target);
        var selectedFileArray:Array = files.fileList;
        for (var i:uint = 0; i < selectedFileArray.length; i++)
            file = FileReference(selectedFileArray[i]);
            file.addEventListener(Event.COMPLETE, completeHandler);
            try
                file.upload(request);
            catch (error:Error)
                trace("Unable to upload files.");
    function completeHandler(event:Event):void
        trace("uploaded");

  • Rendering an image and adding points

    Hi,
    I need some high level guidance as to how add points (as plotting points) to an image. These points (x, y coordinates) will be retrieved from an existing database and plotted on top of an image. I extended a jpanel and overwrote the paint method to paint the image. I was looking for something similar for the points but haven't found anything obvious. The closest thing is paintPolygon() method, but this paints a close shape and all I need is to paint the points. Any help will be much appreciated.
    -thanks
    R

    Hi, thank you for getting back so quick!
    1. its a jpeg file i downloaded from Shutterstock for use on my website. I also have a vector format of the file but i guess for the web i need jpeg.
    2. You can actually see the image here,Gift Cards With Different Red Bows Stock Vector Illustration 119754361 : Shutterstock
    3. I can't make the outline mode work
    4. The whole image gets selected.
    am super grateful! Thank you

  • Problems with Start up after loading Parallel and adding Windows Vista

    Everytime I start up my MacBook, I have to hold the option button down. Otherwise it goes into a booting up windows screen. How do I get the computer to go right to the Mac desktop, when starting up?
    Thanks

    agent412 wrote:
    Everytime I start up my MacBook, I have to hold the option button down. Otherwise it goes into a booting up windows screen. How do I get the computer to go right to the Mac desktop, when starting up?
    Thanks
    You have selected Vista as your boot OS.
    In Leopard, open the System Preferences and under Startup Disk, select Mac OS X, 10.5.whatever and that will solve your problem.
    You can also set the boot preference in Vista, but I am not sure exactly where. BootCamp installs a similar boot option in Vista or XP.

  • If I set Firefox to refrain from loading images automatically, how can I view a single image, or a single page's images, without having to enter the site in the Exceptions list, only to go back and remove it when I'm done?

    I was hoping for a hotkey option or button on the toolbar to load images for a single page for a single session at a time. Turning off images really saves bandwidth and speeds load time on websites, but sometimes I'd like to view the images on a page, but only for this session. Is that possible, or do I have to go to the Exceptions page and allow a specific domain or page to load images and then go back and remove that domain or page when I'm done?

    *Image Block: https://addons.mozilla.org/firefox/addon/image-block/

  • How can I fix the error image and get the regular image to load?

    Ever since the recent big update for Firefox I've been getting some sort of error for loading certain images.
    Here: http://tinypic.com/r/103bf3l/8 I have put one of those sites that give that error
    --The original image that is supposed to show is also available in that image
    Certain sites give a different size of that error image, but it looks the most like an error triangle
    I've already tried the troubleshoot of not loading images and none of the options worked
    If someone has this problem or knows how to fix it, it would be a great help

    Solution found:
    The addon "Stylish" with the theme "Google two themes" interfered with the image loading of the sites. Disabling the theme was the solution.

  • How? Loading Image seqences from actionscript

    Hi,
    I need to load about 60 images where hese images are three animation  sequences each 20 frames long. The first is the idel sequence which runs constanly until a  key is pressed.Once the key is pressed the second animation sequence is  run and so on.
    As animation now consists of a series of images, I dont know how to load  all these images into flash using actionscript and how to run the the animation and switch to different animation when a button is pressed.
    Does anybody kno whow to do this?
    thanks

    You didn't say tidy
    Of course you can make it more tidy by removing and adding the sprite on every frame. A movieclip with a timeline in Flash (afaik) does make it this way too - except you don't see the code for it. But I don't know if you have any benefits by removing them compared to make them visible and invisible (for your static graphics).
    Or make it real tidy and build a quick animation+loader class which you can use in your main class.

  • Yahoo! Mail no longer loads emails and the ads are missing after having cleared Firefox's cookies, history, and cache.

    Ironically, I made this support account just to ask this question and had to go to IE to verify.
    Anyway, Yahoo! Mail use to work almost flawlessly before a couple days ago. Basically, the page loads like normal when I have a good connection except that the ads on the sides are missing, my profile picture is gone, the "fancy" rounded edges of the buttons are nonexistent, none of the menus work or open anything, and all of the links are useless. I have been searching for solutions for two hours now and none of them are relevant or useful:
    - Clear cookies = when I cleared cookies, cache and history is when the problem first started;
    - Disable Ghostery = I just learned about it today and so never installed it, but I also checked to make sure it wasn't there somehow;
    - Start in Safe Mode = the problem is still there and the only change was that it loaded the page faster;
    - Disable AVG = I can't because I can't find it anywhere...;
    - Disable Security/Change Permissions? = I think this was a suggested solution, but it already allows Yahoo! Mail to load images and set cookies while blocking pop-ups, location sharing, and installing themes/extensions;
    - Update Firefox = No. I like my old version. I keep hearing weird and annoying things about updated versions of Firefox, and I'm not going to risk losing everything else just to get Yahoo! Mail back
    I started using Firefox (3.6.12) because IE was slow, but ever since I tried clearing the cache, cookies and history Firefox has been going slower. Oddly enough, all of my browsing history was not deleted because certain web pages (that I haven't accessed in ages) show up in the address bar when I go to type. Gmail works in Firefox despite saying my browser isn't supported, but Yahoo! never bothers me about my browsers and now its acting strange.
    By the way, I don't know if this has anything to do with it, but right before Yahoo! Mail took the usability train off a cliff, it reloaded (because clearing the cookies logged me out), then told me the internet connection was slow and that I can switch to Basic for better results. I decided to stick with Classic and then it "crashed".
    Anyone help with this would be appreciated. One of the reasons I switched to FF is because Yahoo! Mail was faster on it, and I'd hate to have to go back to IE...
    Thanks in advance!

    As it turns out, many others have been having similar issues on other browsers. It seems that maybe Yahoo! is taking a much longer time to load or something like that. Either way, its been working on and off all week, and the same issue even showed up yesterday with IE 8 instead of FF. It still loads faster than IE 8, but again is spotty. Some people think the issue may be with mail.yimg.com or s.yimg.com, which I could see was the loading url in the left corner whenever Yahoo! Mail was refusing to work. A couple of people said blocking it caused the issue. Alternatively, some people suggested blocking it to solve the problem. Does anyone have any information on that? Again, I have no add-ons that would be blocking any urls, and my firewall hasn't any records of it. I really don't want to do anything to mess up my browsers more than they may have already been. Thanks for all of your help so far!

  • Why is LR importing duplicate files and adding a -1 to file name?

    I need to locate some missing photos that disappeared from my library so I'm re-importing my photo collection again (from burnt DVD's) in hopes to recover all the missing images. When I insert a DVD to re-import the photo collection and choose "convert to DNG" and I check "do not import suspected duplicates" LR imports the same images that are already in the catalog and renames the images with a -1...for example, IMG_3664.dng is already in LR folder named 2008-06-14. When I re-import the images from that date, LR renames the image IMG_3664-1.dng and puts it in the same folder resulting in duplicate images side by side. Why is it importing the same image and adding a -1 to the file name?
    I was expecting it to tell me there are XXX photos already in the catalog but it doesn't. It just adds a -1 to the file name and imports all the duplicate images and displays them side by side in the grid view.
    Any ideas? I originally imported the images from the same DVD's I'm using now on a PC and placed the library on an external hard drive. NOw I'm using a new iMAC and I imported that same library from the same external drive location. I'm working with LR 1.31.
    Can someone help? LR should recognize the files with the identical date/time stamp and tell me it's already in the catalog...but it's not for some reason.
    Thanks

    If you import them again, you'll get a "-2" instead of -1, and the -2 will list with the -1,and the original with no dash. The higher number distinguishes the most recent file of same title..
    The file titles are identical as original, but it sounds as converting the file from the source,(PC, Hard drive) to DNG makes it another version of the file....do you type DNG in caps? should it be lower case?
    Because the computer doesn't read the file as a duplicate, but the file name is the same, you'll get a -1.
    This could probably happen,say, if your files are raw, and you had burned them as jpeg onto dvd storage. Even though you want them back as raw, converting them isn't duplicating them.
    I hope this helps...I don't even own Lightroom; I'm shopping around between this and Aperture right now...the experience I'm referring to is where I work in a pre-press printing house; So if someone replying to my post who masters in Lightroom calls me an idiot, I won't argue much!!

  • How can I load images without XML, please?

    Hello Everyone,
    I would highly appreciate it if someone can point me into the right direction. I have some AS2 code which loads up the images via an xml file. I have been asked to eliminate XML entirely and have images be loaded from with in the library. Aside from images, there are other xml nodes such as:
    image_name, image_description and such.
    What would be the best way going about eliminating the XML and getting the code to load images and other related info from the library. I would highly appreciate your help on this, please.
    Thanks a lot.

    create arrays that contain the same info as the xml.
    p.s.  and, you'll use attachMovie() instead of loadMovie().

  • Safari stops loading images randomly

    When I'm using Safari, it will be working fine, and then for some unknown reason, it will just stop loading images, and a small blue box with a question mark will appear instead.
    This happens on all sorts of pages, it can be a page that was loading fine before, then no images will load.
    Also, the problem does eventually go away, and then images start loading again.
    I noticed tonight that it started happening when my battery was low...could it be related to battery power?
    Help! This is very annoying.

    I'd love to know why this seems to have worked...
    DNS - Domain Name System - is the system that tells your computer and web browser where to look for a domain like www.apple.com. The domain is just a name - some system has to be used to figure out where that site actually resides, so it can be loaded in a web browser.
    Basically, each ISP sends you to a DNS server that looks up a domain (e.g. www.apple.com) and figures out what that domain's IP address is (e.g. 17.149.160.49 ). Your web browser is then directed to that physical address and is able to load the web site you were looking for.
    Some DNS servers (nameservers) can be flaky, either not providing updated addresses or being slow to access. Sometimes there are problems in communication somewhere between your computer, your router, your modem, and the DNS server. Often those problems can be fixed by manually entering your ISP's nameserver addresses or by using alternate nameserver addresses. Common alternate nameservers are Verizon's DNS servers (which include the addresses 4.2.2.1 and 4.2.2.2) and the OpenDNS DNS servers (208.67.222.222 and 208.67.220.220).
    By specifying nameserver addresses in your System Preferences or in your router's settings, you are choosing to use a different system for finding web sites than the one your ISP is using and/or you might be solving any communication problems that might exist somewhere between your computer and the nameserver you're using.
    Message was edited by: Rachel R

Maybe you are looking for

  • Reducing file size #2...Preview, Quartz Filter vs Adobe Pro Optimize

    Questions on reducing a pages to pdf file-I will post each question seperatly. 2) I read that you can reduce file size of a pdf in preview with a quartz filter. I created my own filer and it worked as expected. But, I also have Adobe Acrobat Pro, wit

  • Message is getting struck in outbound queue

    Hi All,       I am doing a simple FILE to FILE scenario . The message is getting struck in SMQ2 (inbound queue). If i go to inbound  queue and manually UNLOCK the queue entry then only the message is getting delivered . This is a new installation and

  • Iphone 5 touch problem with cold?

    Hey guys I have an iPhone 5 which works perfectly but in a sudden, now in winter the touch screen began to stop working well, I warm it and my hands and sometimes it works sometimes it doesn't. What could it be?

  • Where can I find cheaper Macbook Pro's?

    Hey everyone! Just wondering do any of you know where I can buy a cheap Macbook Pro? Any second hand websites or refurbished machines? I am finding it hard to find anything suitable. As I live in Ireland the cheapest Macbook Pro I can buy is €1299 as

  • Unable to edit generated Word output

    Hello all, after generating printed Output, the Word document cannot be edited. The entire content can be copied into a new document though and then it can be edited. It makes no difference whether the output into a single Word document or a master i