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 <[email protected]> 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
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders