Be a Supporter!

loading image problem[AS3]

  • 445 Views
  • 9 Replies
New Topic Respond to this Topic
HoundByte
HoundByte
  • Member since: Mar. 16, 2011
  • Offline.
Forum Stats
Member
Level 02
Game Developer
loading image problem[AS3] 2013-03-16 17:53:33 Reply

im tring to load a png inside an enterframe function

addEventListener(Event.ENTER_FRAME, Ani)

and i put this inside the ani function

loader.load(new URLRequest("C:/Users/Guest.jimmy-PC/New Folder/src/Art/Player/1.png"))

but it wont do anything.please help


i did not make with ms paint.

FlyingColours
FlyingColours
  • Member since: Jul. 3, 2011
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to loading image problem[AS3] 2013-03-16 19:59:36 Reply

It seems that Event.ENTER_FRAME is the culprit. I've tried loading a picture with Event.ENTER_FRAME, and then replaced it with Event.ADD_TO_STAGE. The latter works, while the former doesn't.

FlyingColours
FlyingColours
  • Member since: Jul. 3, 2011
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to loading image problem[AS3] 2013-03-16 20:02:07 Reply

At 3/16/13 07:59 PM, FlyingColours wrote: It seems that Event.ENTER_FRAME is the culprit. I've tried loading a picture with Event.ENTER_FRAME, and then replaced it with Event.ADD_TO_STAGE. The latter works, while the former doesn't.

Also, you need to add file:/// in front of the local file's address.

mandog
mandog
  • Member since: Jul. 13, 2010
  • Offline.
Forum Stats
Member
Level 22
Musician
Response to loading image problem[AS3] 2013-03-17 05:55:16 Reply

Am I the only one who notices he makes a URL request and returns a local file request?


original I am.

BBS Signature
mandog
mandog
  • Member since: Jul. 13, 2010
  • Offline.
Forum Stats
Member
Level 22
Musician
Response to loading image problem[AS3] 2013-03-17 05:57:17 Reply

At 3/16/13 05:53 PM, HoundByte wrote: loader.load(new URLRequest("C:/Users/Guest.jimmy-PC/New Folder/src/Art/Player/1.png"))

Heres what you do

1. Upload the image to http://www.myfrogbag.com/

2. loader.load(new URLRequest("http://files.myfrogbag.com/kyozy2/6a0120a721c2d7 970b0163049871f7970d-800wi.jpg"))//Replace URL

3. ???

4. Profit!!!


original I am.

BBS Signature
4urentertainment
4urentertainment
  • Member since: Aug. 1, 2008
  • Offline.
Forum Stats
Moderator
Level 13
Game Developer
Response to loading image problem[AS3] 2013-03-17 07:02:01 Reply

At 3/17/13 05:55 AM, mandog wrote: Am I the only one who notices he makes a URL request and returns a local file request?

URL Request can load local files as well.

FlyingColours
FlyingColours
  • Member since: Jul. 3, 2011
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to loading image problem[AS3] 2013-03-17 10:26:04 Reply

At 3/17/13 07:02 AM, 4urentertainment wrote:
At 3/17/13 05:55 AM, mandog wrote: Am I the only one who notices he makes a URL request and returns a local file request?
URL Request can load local files as well.

I think mandog does have a point, though, since accessing local files might cause security issues...

BTW, HoundByte, are you just including art in your game? If so, why not just embed? ;)

HoundByte
HoundByte
  • Member since: Mar. 16, 2011
  • Offline.
Forum Stats
Member
Level 02
Game Developer
Response to loading image problem[AS3] 2013-03-17 22:37:01 Reply

i want to use a while loop inside a function that would load created

public function load1(evt:Event)
		{	
		
			while(f1)
			{
				loader.load(new URLRequest("C:/Users/Guest.jimmy-PC/New Folder/src/Art/Player/1.png"))
			}
		   	
		}

but flash mesesup because of the loop, i cant use a while loop in a function that isnt enterframe?
thanks


i did not make with ms paint.

FlyingColours
FlyingColours
  • Member since: Jul. 3, 2011
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to loading image problem[AS3] 2013-03-19 05:20:23 Reply

I'm sorry if this doesn't help much... it probably doesn't, but there's a lot of things I don't understand about this. Why are while-loops restricted to enterFrame? Why would you load a picture in an enterFrame function?

I think you should just embed the picture. The player isn't going to look in your C:\ drive...

BTW, again, you need to add file:/// before your address.

seel
seel
  • Member since: Jun. 27, 2005
  • Offline.
Forum Stats
Member
Level 21
Musician
Response to loading image problem[AS3] 2013-03-20 13:05:18 Reply

If you want to embed a local file (which I'm assuming since you're trying to load a file from your harddrive) just use the Embed directive.

public class Main extends Sprite {
[Embed(source = "Art/Player/1.png")]
protected const MyImage:Class;

...

var an_image:Bitmap  = new MyImage() as Bitmap;

Assuming that the Art folder is in the same folder as your .as file. Don't forget to add the bitmap to the desired container using addChild.