Jump to content
Search Community

Type Coercerion failed cannot convert...

stompwampa test
Moderator Tag

Recommended Posts

This is the error I'm getting when I test my movie:

 

TypeError: Error #1034: Type Coercion failed: cannot convert com.greensock.events::LoaderEvent@24b69f21 to flash.events.ProgressEvent.

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at com.greensock.loading::SWFLoader/_progressHandler()

 

And here is my loading code:

 

import com.greensock.events.*;
import com.greensock.loading.*;

stop();

var loader:SWFLoader = new SWFLoader("mySwf.swf",{container:this,x:0,y:0,onProgress:updateText,onInit:addContent,autoDispose:true});

loader.load();

var l:Number;
var t:Number;
var p:Number;	

function updateText(event:ProgressEvent):void
{
l = loader.bytesLoaded;
t = loader.bytesTotal;
p = Math.ceil((l/t)*100);

loader_mc.loader_txt.text = "Loading: " + String(p) + " %";
}

function addContent(event:Event):void
{

trace("loaded");

}

 

Not sure why this is happening...any ideas?

Link to comment
Share on other sites

When your loading with LoaderMax you have to use the event it's sending it as your argument in your function. And that event type is a LoaderEvent not a ProgressEvent. Try this for your function instead.

 

function updateText(event:LoaderEvent):void
{
  l = loader.bytesLoaded;
  t = loader.bytesTotal;
  p = Math.ceil((l/t)*100);

  loader_mc.loader_txt.text = "Loading: " + String(p) + " %";
}

Link to comment
Share on other sites

Oh, duh. That makes sense now.

 

This is my first time trying LoaderMax. I converted an old loader to LoaderMax. I see what I missed now.

 

Now, here's the new problem I'm having:

 

When I test my movie, this is the error that outputs:

 

loaded

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at warrior_fla::MainTimeline/updateText()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at com.greensock.loading::SWFLoader/_progressHandler()

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at warrior_fla::MainTimeline/updateText()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at com.greensock.loading::SWFLoader/_progressHandler()

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at warrior_fla::MainTimeline/updateText()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at com.greensock.loading::SWFLoader/_progressHandler()

TypeError: Error #1009: Cannot access a property or method of a null object reference.

at warrior_fla::MainTimeline/updateText()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at com.greensock.loading::SWFLoader/_progressHandler()

 

And this just cycles over and over again. It traces out 'loaded' and then throws that error as the update even trys to happen and then traces out 'loaded' again. Looks like it keeps trying to load the movie over and over and over again.

 

This only happens when loading this particular movie. If I true to load a different movie from my website, it works just fine. Not sure what's going on here.

Link to comment
Share on other sites

I think that has to do with your l, t and p values.

 

You can just use:

 

//event.target.progress

//So

function updateText(event:LoaderEvent):void
{
  //l = loader.bytesLoaded;
  //t = loader.bytesTotal;
  //p = Math.ceil((l/t)*100);

  loader_mc.loader_txt.text = "Loading: " + String(event.target.progress) + " %";
}

 

to get the progress of the loader instead without all the math and getting of variables if that's what your looking for.

Link to comment
Share on other sites

Nope...that doesn't work either. I get the same error loop/loading loop.

 

The thing is, the loader works fine when I load a different swf file. It's this swf in particular that the loader doesn't like...even though the swf works just fine when I open it by itself.

Link to comment
Share on other sites

I'm pretty sure it's not an error in the ProgressEventHandler function because when I completely skip that part, I still get my Complete even to trace out 'loaded' over and over and over again.

 

But yeah...it's likely not anything from LoaderMax. Looks like I gotta keep digging.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...