• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

AS3 Flash pro Banner Ad

Explorer ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

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!

TOPICS
ActionScript

Views

2.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

You are right no errors are normal.. = ) that is why they are errors..

Sorry about that code, it is not "clickHandler" as in the above code, I changed it to "buttonHandler" because this is the way it comes in the example code in Flash for templates.

I debuged and this is the outcome:

Attempting to launch and connect to Player using URL /Users/POL/Desktop/Banners/42W_160/42W_160.swf

[SWF] Users:POL:Desktop:Banners:42W_160:42W_160.swf - 32052 bytes after decompression

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

          at _42W_160_fla::MainTimeline/buttonHandler()[_42W_160_fla.MainTimeline::frame1:4]

1  invisClick.addEventListener(MouseEvent.CLICK, buttonHandler);

2  function buttonHandler(event:MouseEvent):void {

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

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

5      navigateToURL(new URLRequest(clickTAG));

6      }

7  }

it seems that in line 4 the code might be obsolete... the course says that is for preventing the add to be highjacked... sould I remove it all? and do you happen to know any new options that works that does the same?

Thank you!

p.s. by the way, I am in Flash CS6

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

I don't think line 4 is the problem, but it is the source of the error message because clickTag is not instantiated at that point. 

Line 3 is not correct whatever it is trying to do.  My guess is that instead of what you show it should be more like...

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

ok, I changed the line you said, I test in flash and I still get this only when I click:

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

          at _42W_160_fla::MainTimeline/buttonHandler()

I published, then I updated the HTML file as before: after the "swf" in the HTML code as follows:

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

then I opened it in browser and the finger pointer doesn't appear, but if I click it works and opens a new window and goes to the specified url.

could I say it works now? (because the other error is still there), also it is weird that the banner doesn't change the mouse pointer from arrow to finger (as it has a link) while hover it.

thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

If you still get the error, there is still something wrong, but without showing the entire error message I can't help.

If invisClick is a MovieClip symbol, you haven't showed anything being done to make it behave like a button, so I cannot say if that's why.  My earlier reply addressed how to make it so.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 05, 2012 Jul 05, 2012

Copy link to clipboard

Copied

ok this is the entire error as you instructed to obtain:

Attempting to launch and connect to Player using URL /Users/POL/Desktop/Banners/42W_160/42W_160.swf

[SWF] Users:POL:Desktop:Banners:42W_160:42W_160.swf - 32049 bytes after decompression

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

          at _42W_160_fla::MainTimeline/buttonHandler()[_42W_160_fla.MainTimeline::frame1:4]

invisClick is a button.

Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 06, 2012 Jul 06, 2012

Copy link to clipboard

Copied

LATEST

Hello, are you still there?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines