Skip to main content
Participating Frequently
July 5, 2012
Question

AS3 Flash pro Banner Ad

  • July 5, 2012
  • 1 reply
  • 2197 views

ERROR

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@2d093e41 to fl.motion.AnimatorFactory.

CODE

import flash.events.MouseEvent;

import flash.net.URLRequest;

// ......

invisClick.addEventListener(

   MouseEvent.CLICK,

   function(event: MouseEvent) : void {

     flash.net.navigateToURL(new URLRequest( root.loaderInfo.parameters.clickTAG), "_blank");

     }

   );

When I publish and open the HTML in browser the mouse pointer doesn't change from arrow to hand indicating link, but if I click on it it does go to the url.

THANK YOU!

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
July 5, 2012

If invisClick is a MovieClip, you need to set it to behave like a button ( as in invisClick.buttonMode = true;). 

You should not be nesting that function in the event listener.  Keep the function outside and just reference it by name in the listener.

POLMXNAuthor
Participating Frequently
July 5, 2012

Thank you for your response Ned!

I'm doing some banner ads, but I have no programing knowledge at all. I copied the above code from a website about ClickTAG.

Now I have changed the code to this one:

invisClick.addEventListener(MouseEvent.CLICK, buttonHandler);

function buttonHandler(event:MouseEvent):void {

          navigateToURL(new URLRequest("http://www.42wins.com/"));}

it shows no errors, but the problem is that I can't add the clickTAG feature without getting errors.

Now I copied and changed to this code:

invisClick.addEventListener(MouseEvent.CLICK, buttonHandler);

function buttonHandler(event:MouseEvent):void {

          var clickTAG:String; - root.loaderInfo.parameters.clickTAG;

          if(clickTAG.substr(0,5)=="http:"){

          navigateToURL(new URLRequest("http://www.42wins.com/"));

          }

          }

I don't get syntax errors but when I test my ad in flash I get this error:

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

          at _42W_160_fla::MainTimeline/clickHandler()

I understand that this is normal because of hte coding, I am supposed to test in HTML to see it work.

I also changed the HTML code in DW and added the following after three swf's...

....swf?clickTAG=http://42wins.com"

Now I test the HTML file and nothing happens, even the finger pointer does not appear, only the arrow pointer, as it has no link..

I am confused, I did all this following a lynda.com ad banner course, but is not working for me.

I am no programmer nor flash expert so pretty sure I am doing something wrong.

Could you help me with that code please?

Thank you for your time!

Ned Murphy
Legend
July 5, 2012

First, you should not ignore error messages -  there is nothing normal about them, especially the 1009 error - it indicates some object your code is targeting does not exist. 

Go into your Flash Publish Settings and select the option to Permit Debugging.  What that will do is add information to the error message, particularly the line number of the offending code. 

Since your code above does not include a function named clickHandler, that could be related to the problem... you might have some old code that needs to be removed.