Re: [Flashcoders] Loading image on local filesystem
use relative path and forward slashes img/image.jpg - Original Message - From: K-Dawg kdaw...@gmail.com To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Thursday, January 29, 2009 1:12 AM Subject: [Flashcoders] Loading image on local filesystem The AS is in a dir1 (dir1\stuff.as) and the images are in dir1\img\image.jpg. imagePath = new URLRequest(this.imagePathString); loader = new Loader(); trace(loader.load(imagePath)); this.imagePathString is a relative path to the image (img\image.jpg). How can I load these from a local filesystem? This will be moved to a web server but for testing I am running on windows and Flash CS3 in Windows XP as a vm on my laptop in VMWare. Thanks for any help. Kevin ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Loading image on local filesystem
On Thu, Jan 29, 2009 at 6:51 AM, Muzak p.ginnebe...@telenet.be wrote: use relative path and forward slashes img/image.jpg I'm sorry, I mistyped for some reason. The actual string passed into the URLRequest is: img/food_array.jpg the path is relative and does exist exactly as that. I pass it in through the object's constructor and then do: this.imagePath = new URLRequest(this.imagePathString); loader = new Loader(); loader.load(this.imagePath); loader.contentLoaderInfo.addEventListener(Event.INIT, imageLoaded); When I trace(this.imagePathString); it outputs the correct path and trace(this.imagePath) returns the URLRequest. I must be doing something incorrect on the loader.load line maybe? Thanks. Kevin ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Loading image on local filesystem
What's the error? No image appearing? (You haven't used addChild() anywhere.) imageLoaded() never getting called? (Probably a red herring, but you really should add the listener _before_ you call load()). Give us some more info, then we might be able to help. Ian On Thu, Jan 29, 2009 at 1:30 PM, K-Dawg kdaw...@gmail.com wrote: On Thu, Jan 29, 2009 at 6:51 AM, Muzak p.ginnebe...@telenet.be wrote: use relative path and forward slashes img/image.jpg I'm sorry, I mistyped for some reason. The actual string passed into the URLRequest is: img/food_array.jpg the path is relative and does exist exactly as that. I pass it in through the object's constructor and then do: this.imagePath = new URLRequest(this.imagePathString); loader = new Loader(); loader.load(this.imagePath); loader.contentLoaderInfo.addEventListener(Event.INIT, imageLoaded); When I trace(this.imagePathString); it outputs the correct path and trace(this.imagePath) returns the URLRequest. I must be doing something incorrect on the loader.load line maybe? Thanks. Kevin ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Loading image on local filesystem
Are you sure this is not a security error due to the allow network / allow local setting? I'm guessing that you may want to allow local file access for the swf (somewhere in publish settings as I remember), or add the img folder on your local drive to flash's trusted locations. -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of K-Dawg Sent: 29 January 2009 13:30 To: Flash Coders List Subject: Re: [Flashcoders] Loading image on local filesystem On Thu, Jan 29, 2009 at 6:51 AM, Muzak p.ginnebe...@telenet.be wrote: use relative path and forward slashes img/image.jpg I'm sorry, I mistyped for some reason. The actual string passed into the URLRequest is: img/food_array.jpg the path is relative and does exist exactly as that. I pass it in through the object's constructor and then do: this.imagePath = new URLRequest(this.imagePathString); loader = new Loader(); loader.load(this.imagePath); loader.contentLoaderInfo.addEventListener(Event.INIT, imageLoaded); When I trace(this.imagePathString); it outputs the correct path and trace(this.imagePath) returns the URLRequest. I must be doing something incorrect on the loader.load line maybe? Thanks. Kevin ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders __ This communication is from Primal Pictures Ltd., a company registered in England and Wales with registration No. 02622298 and registered office: 4th Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT registration No. 648874577. This e-mail is confidential and may be privileged. It may be read, copied and used only by the intended recipient. If you have received it in error, please contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 1010. Please then delete the e-mail and do not disclose its contents to any person. This email has been scanned for Primal Pictures by the MessageLabs Email Security System. __ ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Loading image on local filesystem
What's the error? No image appearing? (You haven't used addChild() anywhere.) Well, what I have my main class, PondoShow that extends Sprite. In here I instantiate a Slide object, passing in a bunch of parameters: slides = new Array(4); slides[0] = new Slide(This is a test, this is only a test, img/food_array.jpg, Click here to find out more, more.html, 100, 100, 50, 50, 200, 200); slides[1] = new Slide(This is a test, this is only a test, img/food_array2.jpg, Click here to find out more, more.html, 100, 100, 50, 50, 200, 200); Inside the slide object constructor I instantiate the variables and then, still inside the constructor of the Slide object: this.imagePath = new URLRequest(this.imagePathString); loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.INIT, imageLoaded); loader.load(this.imagePath); } private function imageLoaded(ev:Event):void { trace(inside imageLoaded function); imgload = true; } My PondoShow class does this: while(true) { if (slides[slideCounter].imgload) { addChild(slides[slideCounter].loader.content); break; } } but in the loop, the if statement is never true, and the imageLoaded function never gets called in the Slide class and eventually the loop times out or I kill it. imageLoaded() never getting called? (Probably a red herring, but you really should add the listener _before_ you call load()). Good idea. Certainly more readable at the very least. Unfortunately changing this did not solve my issue though. Give us some more info, then we might be able to help. Ian Thanks for any help. Kevin ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Loading image on local filesystem
On Thu, Jan 29, 2009 at 8:53 AM, Jim Hayes j...@primalpictures.com wrote: Are you sure this is not a security error due to the allow network / allow local setting? I'm guessing that you may want to allow local file access for the swf (somewhere in publish settings as I remember), or add the img folder on your local drive to flash's trusted locations. In the Publish Settings I see a Local Playback security and it is set to access local files only. Thanks. Kevin ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Loading image on local filesystem
while(true) { if (slides[slideCounter].imgload) { addChild(slides[slideCounter].loader.content); break; } } This is your issue. Flash just doesn't work like this. You are repeatedly executing the code in the while loop, giving Flash no chance to do anything else - update the screen, fire events, anything at all. The correct answer is to listen for the Event.INIT to be fired (as you are doing) and then call your addChild function. I'd really suggest you take a look at some tutorials on Flash's event system. There are plenty around the web - or, better, consider buying yourself a book on ActionScript. Rich's book would be ideal: http://www.amazon.com/gp/product/059652787X Cheers, Ian On Thu, Jan 29, 2009 at 2:13 PM, K-Dawg kdaw...@gmail.com wrote: What's the error? No image appearing? (You haven't used addChild() anywhere.) Well, what I have my main class, PondoShow that extends Sprite. In here I instantiate a Slide object, passing in a bunch of parameters: slides = new Array(4); slides[0] = new Slide(This is a test, this is only a test, img/food_array.jpg, Click here to find out more, more.html, 100, 100, 50, 50, 200, 200); slides[1] = new Slide(This is a test, this is only a test, img/food_array2.jpg, Click here to find out more, more.html, 100, 100, 50, 50, 200, 200); Inside the slide object constructor I instantiate the variables and then, still inside the constructor of the Slide object: this.imagePath = new URLRequest(this.imagePathString); loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.INIT, imageLoaded); loader.load(this.imagePath); } private function imageLoaded(ev:Event):void { trace(inside imageLoaded function); imgload = true; } My PondoShow class does this: while(true) { if (slides[slideCounter].imgload) { addChild(slides[slideCounter].loader.content); break; } } but in the loop, the if statement is never true, and the imageLoaded function never gets called in the Slide class and eventually the loop times out or I kill it. imageLoaded() never getting called? (Probably a red herring, but you really should add the listener _before_ you call load()). Good idea. Certainly more readable at the very least. Unfortunately changing this did not solve my issue though. Give us some more info, then we might be able to help. Ian Thanks for any help. Kevin ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Loading image on local filesystem
The AS is in a dir1 (dir1\stuff.as) and the images are in dir1\img\image.jpg. imagePath = new URLRequest(this.imagePathString); loader = new Loader(); trace(loader.load(imagePath)); this.imagePathString is a relative path to the image (img\image.jpg). How can I load these from a local filesystem? This will be moved to a web server but for testing I am running on windows and Flash CS3 in Windows XP as a vm on my laptop in VMWare. Thanks for any help. Kevin ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders