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

How do you put in an ActionScript3 ClickTag?

New Here ,
Dec 17, 2013 Dec 17, 2013

New to Flash Professional and ActionScript3 so please bare with me. Tried to insert a ClickTag the way you would in AS2 and it doesn't work.

This is is the code I need to put in, but I am not sure how to get it to work:

import flash.events.MouseEvent;
import flash.net.URLRequest;
// ......
someButton_or_displayObject_to_receive_mouseClick.addEventListener(
    MouseEvent.CLICK,
    function(event: MouseEvent) : void {
      flash.net.navigateToURL(new URLRequest( root.loaderInfo.parameters.clickTAG), "_blank");
      }
    );

Also, do I need to put the Stop Action in the same layer or can in be in a separate layer?

Thanks!


TOPICS
ActionScript
816
Translate
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 ,
Dec 17, 2013 Dec 17, 2013

You need to be testing with the html page in case you aren't.

Separate the function from the listener and see if you get better results... 

someButton_or_displayObject_to_receive_mouseClick.addEventListener(MouseEvent.CLICK, clickedBtn);

function clickedBtn(event: MouseEvent) : void {

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

}

If that doesn't help, add a textfield temporarily and assign it the value of the clickTag to make sure it is being read properly

It is okay to put the stop() in the same layer

Translate
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
New Here ,
Dec 18, 2013 Dec 18, 2013

Hi Ned,

I've been uploading to Double Click by Google and testing the .swf files there with no success. I don't think I am doing the correct steps in Flash to make the click tag work. I found a tutorial and followed these steps with no luck...

1. Created a box over the ad using a rectangular primitive tool and changed the alpha to 0%.

2. Converted it to a button and named it someButton

3. Opened Actions > Event Handlers > Mouse Click Event

4. Put the above code in after the generated code:

button_3.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_3);

function fl_MouseClickHandler_3(event:MouseEvent):void

{

someButton_or_displayObject_to_receive_mouseClick.addEventListener(Mou seEvent.CLICK, clickedBtn);

function clickedBtn(event: MouseEvent) : void {

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

}

5. Exported and tested in Double Click.

I got these directions from a tutorial and they don't seem to work. Do you see anything I might be doing wrong?

Thanks for your help!

Lindsay

Translate
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 ,
Dec 18, 2013 Dec 18, 2013
LATEST

You are coding for two buttons and I do not see the sense in it.  Clicking button3 only serves to add clicking functionality to something named "someButton_or_displayObject_to_receive_mouseClick"  but you say you named your button "someButton"  The code needs to target the button using the name you used for the button.  If your button is named someButton, then the following is all the code you should need...

someButton.addEventListener(Mou seEvent.CLICK, clickedBtn);

function clickedBtn(event: MouseEvent) : void {

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

}

... and "someButton" is assigned via the Properties panel... it is not the name of the object in the library.

You appear to have the second function nested within the first function... get it out of there and let it stand on its own.

You also need to make sure your html page defines the clickTag parameter.

Translate
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