Several buttons call function to link to a unique URL?

Howdy,

So, I've got tons o ' buttons that each must make a link to unique URLS, and I want to minimize as much as possible of coding.  The code below works, but I'll have to do it about 50 times. Can I associate URLS with the button instance names and then reuse the same function?

In case you don't to already guess, I am a newbie to AS3

cap_mc. CapTeam_btn.addEventListener (MouseEvent.CLICK, capPage);

function capPage (evtObj:MouseEvent) {}
trace ("clicked")
var url: String = " " http://www.mydomain.com ";
var request: URLRequest = new URLRequest (url);
try {}
navigateToURL (request, "_blank");
} catch (error) {}
trace ("Error occurred!");
}

}

Thanks in advance!

You can.  the easiest way is to use a movieclip button (because the movieclip class is dynamic you can add properties):

cap_mc. CapTeam_mc.addEventListener (MouseEvent.CLICK, capPage);

cap_mc. CapTeam_mc.urlS = "http://www.mydomain.com."

function capPage (e:MouseEvent) {}

navigateToURL (new URLRequest (e.currentTarget.urlS));

}

but you can also create an object to associate the button names with url strings and still use the buttons.

Tags: Adobe Animate

Similar Questions

  • Export csv button call don't link not?

    GDay,

    I was wondering if it is possible to call the export csv via a button feature and functionality of default hyperlink?

    See you soon

    Hello

    You really need to mess with two models - the region one and a new button we.

    First of all, update model area of the report to include the following in the upper part of the setting "Template":

    <script type="text/javascript">
    var regionid="#REGION_ID#"
    </script>
    

    Note that this must be done on the model of the report, even if you put your button in another region because we need value REGION_ID report

    Now create a new model of button called, say, "Export" button The 'model' for this must be set:

    <a href="javascript:void(0)" class="t12Button" onclick="doExport();">Export</a>
    

    This was based on a standard model of button "button. If you use a different style of button, adjust accordingly - you need the same attributes href and onclick as shown above, but nothing else can be unchanged.

    Finally, the parameter header HTML of the page, add:

    <script type="text/javascript">
    function doExport()
    {
     var url = 'f?p=&APP_ID.:&APP_PAGE_ID.:&SESSION.:FLOW_EXCEL_OUTPUT_' + regionid + '_en';
     document.location.href=url;
    }
    </script>
    

    You can now change your button in a button-based model by using the new export button.

    Note that, as we are assigning to a javascript variable, 1 REGION_ID only this button can exist on a page.

    Andy

  • Disappear several buttons to create the message window after installing Enigmail and GNUpg

    Hello.

    I decided to install the Thunderbird PGP module (Enigmail). During the installation, it was necessary to install additional software GnuPG. After restart Thunderbird in create message windows several buttons disappear as: fonts, links, etc. (see photo).

    I uninstalled Enigmail and GnuPG, but the situation with row of missing button has not changed.

    I installed the new Thunderbird software at the top of the old installation and don't change the situation with row of button disappeared.

    I repeat the installation on a new computer to get started with Thunderbird and after that with Enigmail and GNUPG and I got the same result with line disappears in create message window.

    Thank you in advance.
    Cryospin

    Enigmail works very well with HTML email. That's why default Enigmail to plain text message composition. The installation wizard did ask you if it
    should these settings and let you inspect these changes.
    You must undo the changes in the settings of your account under Composition & addressing. Just check "compose messages in HTML format.

  • several buttons with very similar functions

    I use the code has a button that adds a MC to step below. The problem is that I have over a dozen of these buttons and I would rather not write the listener of events and the function for every single button. Is there a way to use a single function for all buttons and just change that MC is added based on which button is clicked? So if the user clicks the button draw5 function adds the MC deck5 to the scene?

    var drawnCard:MovieClip

    Draw1.addEventListener (MouseEvent.MOUSE_DOWN, dealTheCard);

    var alreadyDrawn:Boolean = false

    function dealTheCard(event:MouseEvent):void {}

    if (alreadyDrawn == true) {}

    this.removeChild (drawnCard);

    trace ("removed card")

    }

    drawnCard = new deck1();

    alreadyDrawn = true

    addChild (drawnCard);

    drawnCard.x = 60;

    drawnCard.y = 50;

    drawnCard.gotoAndStop (Math.ceil (Math.random () * 11))

    }

    use:

    kglad wrote:

    var drawnCardObj:Object = {};

    var tl:MovieClip =;

    for (var i: int = 1; i<>

    TL ['draw' + i] .addEventListener (MouseEvent.MOUSE_DOWN, dealTheCard);

    .Ivar TL ['draw' + i] = i;

    }

    var alreadyDrawn:Boolean = false

    function dealTheCard(event:MouseEvent):void {}

    If (drawnCardObj [MovieClip (event.currentTarget) .ivar]) {}

    tl.removeChild (drawnCardObj [MovieClip (event.currentTarget) .ivar]);

    }

    var classRef: Class = Class (getDefinitionByName ("bridge" + MovieClip(event.curre_ntTarget).ivar));

    var drawnCard: * = new classRef();

    drawnCardObj [MovieClip (event.currentTarget) .ivar] = drawnCard;

    tl.addChild (drawnCard);

    drawnCard.x = 60;

    drawnCard.y = 50;

    drawnCard.gotoAndStop (Math.ceil (Math.random () * 11))

    }

  • Several HTTPService calls...

    Several HTTPService calls to different XML files...

    I have several XML files with data. They all have the same structure but different content. I want to call these XML files and display them in the same provision, having a substitute the previous result. Sounds simple, but I are confused...

    Let's say I have two buttons of the HTTPService calls,
    < mx:Button... click = "Serv1.send ()" >
    < mx:Button... click = "Serv2.send ()" >

    < mx:HTTPService id = "Serv1" url = "data1.xml" >
    < mx:HTTPService id = "Serv2" url = "data2.xml" >

    I have a provision any which goes something like this...
    < mx:TileList... dataprovider="{Serv1.lastResult.collection.object}"/ >

    Let's say I want the second button and call Serv2 and its results place in the TileList. I read about ArrayCollections and models and by sending the service-results of a function and import utilities and result of the event, but I'm a little confused.

    QUESTION:
    Can I just that and please correctly interpret me here... "Serv1.result = Serv2.result;" If you catch my drift?

    PS: As you can imagine, I had trouble getting a thing going and expanded on it quite well and all I want is to add another button, without having to redo everything from scratch...

    Ok. To make it work.


    public function copyHTTP (): void {}
    SERV1 = Serv2;
    }



  • Calling functions / set variables in loaded SWF

    You know how you can create a Movieclip object, add a function or a variable, and then call this function or change this variable to the SWF file that includes? I want to be able to do it, only with SWFs that are loaded at run time.

    My "main" SWF is just something the type of menu. The user clicks a button in my HAND. SWF and the HAND. SWF and then load the SWF associated with this button, using the AS 3.0 method Loader () - URLRequest () - addChild () that everyone always asks questions on prescribed.

    It works very well. But now I have a few custom and other objects (ie., not only the channels) in my HAND. SWF I want power sharing with the loaded SWF files. preferably, I'd use a function of the type of accessor (ie., LoadedSWF.GiveMeTheCoolObject (MyCoolObject)); Although at this point, I'm willing to hack the object itself (ie., LoadedSWF.CoolObject.CoolField = MyCoolObject.CoolField ;) if that's what it takes.

    I tried to call the functions and setting the fields, but the AS 3.0 compiler doesn't care for this kind of nonsense on its objects defined by the generically. Also note that, at runtime, a call to LoadedSWF.hasOwnObject ("GiveMeTheCoolObject") returns true.

    So my colleagues big brain, what is the magic?

    In advance, thank you for the help!
    Scott

    Kglad,

    Quote:
    Posted by: kglad
    the error message, seems, your function expects a member of the class MyCoolObject, correct?
    and MyCoolObject is not an instance of this class. so, you have to fix that. That is to say, create a member of this class, and use this class as a parameter of the function member.

    Heh, that's what the error message says all right. But the object IS actually an object of class MyCoolObject. I looked at this thing for hours and MyCoolObject IS an instance of this class. I tried different combinations of casting (including the cast on an object and passing that) but had no luck whatsoever.

    So I googled this particular runtime error message ("Error #1034: has no Type constraint: cannot convert '" ") and found a ton of links to other people with a similar problem. As a general rule, the problem was just as you say, someone passes a button as a string, that kinda thing. But a guy had a problem with an object that it has derived from the event class. Once the hours spent trying to make it work, he has tried to override clone() of the base class method and got it to work:

    http://www.assertTrue.com/articles/2006/10/14/custom-events-in-ActionScript-3-0

    As for my project, I took a long, hard look at the overall architecture of my project and decided it would be better if all the 'real work' is held in the HAND. SWF file. This approach would solve some other problems, and it makes sense in a mindset of "separating the display of data.

    If (and this is the interesting part) I changed the API for the LOADED. SWF to accept the pairs of strings (ie., LoadedSWF.AddToDisplay (String Name, String Data)) rather than accept MyCoolObj. Ran and Viola, now we work without any throw exceptions in. After this moment of glory, I created a couple of other APIs that comes from base classes (a type int, the other a type function) agreed and was happily on my way.

    On this basis, I understand while passing another base class objects (IE, the derived class) to load MovieClips via custom function API is... perhaps not so simple you'd expect. In the grand scheme of things well, not a big deal: as far as I'm concerned AS3 rocks.

    Kglad, thanks again for all the help: your comments on how this was the big push that I needed to get through the last barrier of this project.

    For those who read this topic for the ' how to call functions or set variables in a loaded SWF file?

    The short answer is cast to the SWF file that is loaded as a MovieClip content object and then call the function or change the variable:

    Load the SWF file (you saw this code a million times)
    var LoadedSWFObj:Loader = new Loader();
    var MyURL:URLRequest = new URLRequest("LoadThisSWF.SWF");
    LoadedSWFObj.load (MyURL);

    It is within your Event.COMPLETE Manager:

    Cast as a MovieClip object and work with it.
    var LoadedSWF:MovieClip = LoadedSWFObj.content as MovieClip;

    or another way to perform a cast:
    var LoadedSWF:MovieClip = MovieClip (LoadedSWFObj.content);

    Call yer function:
    LoadedSWF.CallMe ();

  • Sims House Party, the installation program starts, then immediately closes, gives me the error "0 x 80040707 - call function DLL crashed: SORTS." PathGetSpecialFolder.

    original title: error number: 0 x 80040707
    When I try to install the Sims House Party, the installer launches and then immediately closes, gives me the error "0 x 80040707 - call function DLL crashed: SORTS." PathGetSpecialFolder.

    According to the compatility of Windows 7, the House Party is compatible under 64-bit and 32-bit Windows 7. I tried to install it on another computer running Windows 7 32 bit and the error does not occur.

    I am running Windows 7 Professional 64 bit.

    Looks like that method 1 solved my problem.  Normally, I would get this message several times a day.  For more than 3 hours I applied the method 1, and the error has not appeared again.  Thank you very much.

  • I received several phone calls from a person claiming there is problem on my pc

    original title: phone calls

    I received several phone calls from a person claiming it is your business. Is this a real employee with your company? He says there is a problem with my PC and he can fix my computer. Is it a scam?

    Please see the article on the link below.
    http://answers.Microsoft.com/en-us/Windows/Forum/windows_xp-security/i-received-a-phone-callemail-from-someone-saying/968f23dc-b7c1-4C8E-95A2-f89dde500ab8

  • I have to do, if this error message appears: "JavaScript exception: error calling function selector: [object Error]? It seems that by Internet Explorer. Thank you very much for your reply and I hope you can help me.

    I have to do, if this error message appears: "JavaScript exception: error calling function selector: [object Error]? It seems that by Internet Explorer. Thank you very much for your reply and I hope you can help me.

    Hi Brad,

    Here is the link: http://projektw.primo-werbung.de/

    We have this problem only by Internet Explorer. Mozilla, Safari and Opera - there is all right.

  • Call function scene MC

    Question: How can I call function of MC in the first image of the stadium?


    Example:

    First MC: ToggleButton have the function:

    function setSelected (b)

    {

    selected = b;

    If (selected)

    _this.gotoAndStop ("DN");

    on the other

    _this.gotoAndStop ("up");

    }

    This code working fine inside MC...

    This place of button on the stage with the instance name: btn_mc

    When I write Action in the first image of the stage: this.btn_mc.setSelected (true) in the output window of the browser, I got an error message: setSelected is not a function.

    You must declare the function to make it accessible. Try this inside the movieclip:

    setSelected var = setSelected;

    function setSelected (b)

    {

    selected = b;

    If (selected)

    _this.gotoAndStop ("DN");

    on the other

    _this.gotoAndStop ("up");

    }

    Then, it should work out the movieclip:

    This. ToggleButton.setSelected (true);

  • Several buttons to toggle (for audio playback/stop)?

    Hello

    I was able to create a toggle button play/stop for a song with the following code

    (I have 2 buttons for a symbol of video layer and then import an mp3 file):

    toggle_btn. Stop();

    var played: Boolean = false;

    var mySound:Sound = new MySound();
    var myChannel:SoundChannel = new SoundChannel();
    toggle_btn.addEventListener (MouseEvent.Click, togglePlay);

    function togglePlay(event:MouseEvent):void {}
    (! played)? played = true: played = false;
    (played)? myChannel = mySound.play ():SoundMixer.stopAll();

    (played)? toggle_btn.gotoAndStop (2):toggle_btn.gotoAndStop (1);

    myChannel.addEventListener (Event.SOUND_COMPLETE, soundCompleted);
    }
    function soundCompleted(event:Event):void {}
    played = false
    toggle_btn.gotoAndStop (1)
    }

    The problem is, I can't understand how to do several buttons to toggle different songs in a single file. Thanks for the help!

    I use Adobe Flash Pro CC 2015 and ActionScript 3.0

    Change the sound: mySound = new theSong();

  • Mobile 'Call' function on the web page

    Hello! Almost ready to publish Web pages, I have a button 'Call' inserted into a thumbnail that links to another page in the site.

    Is it possible to activate this button, dial the number on a mobile Web page? Or at least

    Show number immediately when they are affected so that the user can activate call, rather than having to navigate to the contact page?

    Thank you, Jon

    Hello Jonrees1978,

    Click on the button and update the "links section" of the properties panel with Tel: 555-555-5555 and it should work for you.
    Replace 555-555-5555 by a number of your choice.

    Please let me know if you are talking about something else.

    Kind regards

    Vivek

  • MuseJSAssert: Error calling function selector: TypeError: $(...). toBrowserWidth is not a function

    HELP PLEASE:

    Error appearing on a website downloaded (as you view on the internet browser) as follows:

    MuseJSAssert: Error calling function selector: TypeError: $(...). toBrowserWidth is not a function

    Am new to Muse and if you can tell me what I did wrong, I would be very happy!

    Hello

    Please visit the following link http://forums.adobe.com/message/6163220#6163220

    Kind regards

    Aish

  • Conditional If/Else with several buttons...

    So, I'm new to Flash and I'm creating a game in which an animated character picks up different objects, and the user must take the correct form and the color of objects.  Therefore, I have two sets of buttons, six colors and three shapes (triangle, rectangle, circle).  I understand that I must use an If/Else condtional to stop in this specific image and then pick up back as key as soon as the correct form and color button are pressed.  However, no matter how to do, I can't do the gotoAndStop command works.  I realize account that its because I'm not the only variable specific must be placed in the conditional, so that he can work.  In any case, I'll post the code I have.

    var hitgreen_rake:Boolean = false;

    var hitblue_rake:Boolean = false;

    var hitpurple_rake:Boolean = false;

    var hitorange_rake:Boolean = false;

    var hitred_rake:Boolean = false;

    var hityellow_rake:Boolean = false;

    var hitrectangle_rake:Boolean = false;

    var hittriangle_rake:Boolean = false;

    var hitcircle_rake:Boolean = false;

    button_triangle_rake.addEventListener (MouseEvent.CLICK, button_triangle_rakeclick);

    function button_triangle_rakeclick(event:MouseEvent):void {}

    hittriangle_rake = true;

    If {(hittriangle_rake)

    button_triangle_rake. Enabled = False

    button_rectangle_rake. Enabled = True

    button_circle_rake. Enabled = True

    }

    }

    button_rectangle_rake.addEventListener (MouseEvent.CLICK, button_rectangle_rakeclick);

    function button_rectangle_rakeclick(event:MouseEvent):void {}

    hitrectangle_rake = true;

    If {(hitrectangle_rake)

    button_triangle_rake. Enabled = True

    button_rectangle_rake. Enabled = False

    button_circle_rake. Enabled = True

    }

    }

    button_circle_rake.addEventListener (MouseEvent.CLICK, button_circle_rakeclick);

    function button_circle_rakeclick(event:MouseEvent):void {}

    hitcircle_rake = true

    If {(hitcircle_rake)

    button_triangle_rake. Enabled = True

    button_rectangle_rake. Enabled = True

    button_circle_rake. Enabled = False

    }

    }

    button_green_rake.addEventListener (MouseEvent.CLICK, button_green_rakeclick);

    function button_green_rakeclick(event:MouseEvent):void {}

    hitgreen_rake = true;

    If {(hitgreen_rake)

    button_green_rake. Enabled = False

    button_blue_rake. Enabled = True

    button_purple_rake. Enabled = True

    button_orange_rake. Enabled = True

    button_red_rake. Enabled = True

    button_yellow_rake. Enabled = True

    }

    }

    button_blue_rake.addEventListener (MouseEvent.CLICK, button_blue_rakeclick);

    function button_blue_rakeclick(event:MouseEvent):void {}

    hitblue_rake = true;

    If {(hitblue_rake)

    button_green_rake. Enabled = True

    button_blue_rake. Enabled = False

    button_purple_rake. Enabled = True

    button_orange_rake. Enabled = True

    button_red_rake. Enabled = True

    button_yellow_rake. Enabled = True

    }

    }

    button_purple_rake.addEventListener (MouseEvent.CLICK, button_purple_rakeclick);

    function button_purple_rakeclick(event:MouseEvent):void {}

    hitpurple_rake = true;

    If {(hitpurple_rake)

    button_green_rake. Enabled = True

    button_blue_rake. Enabled = True

    button_purple_rake. Enabled = False

    button_orange_rake. Enabled = True

    button_red_rake. Enabled = True

    button_yellow_rake. Enabled = True

    }

    }

    button_orange_rake.addEventListener (MouseEvent.CLICK, button_orange_rakeclick);

    function button_orange_rakeclick(event:MouseEvent):void {}

    hitorange_rake = true;

    If {(hitorange_rake)

    button_green_rake. Enabled = True

    button_blue_rake. Enabled = True

    button_purple_rake. Enabled = True

    button_orange_rake. Enabled = False

    button_red_rake. Enabled = True

    button_yellow_rake. Enabled = True

    }

    }

    button_red_rake.addEventListener (MouseEvent.CLICK, button_red_rakeclick);

    function button_red_rakeclick(event:MouseEvent):void {}

    hitred_rake = true;

    If {(hitred_rake)

    button_green_rake. Enabled = True

    button_blue_rake. Enabled = True

    button_purple_rake. Enabled = True

    button_orange_rake. Enabled = True

    button_red_rake. Enabled = False

    button_yellow_rake. Enabled = True

    }

    }

    button_yellow_rake.addEventListener (MouseEvent.CLICK, button_yellow_rakeclick);

    function button_yellow_rakeclick(event:MouseEvent):void {}

    hityellow_rake = true;

    If {(hityellow_rake)

    button_green_rake. Enabled = True

    button_blue_rake. Enabled = True

    button_purple_rake. Enabled = True

    button_orange_rake. Enabled = True

    button_red_rake. Enabled = True

    button_yellow_rake. Enabled = False

    }

    }

    If (hittriangle_rake == true & & hitgreen_rake == true) {}

    gotoAndPlay (40)

    } else {}

    Stop()

    }

    I assume that the problem is in the last few lines, and I'm simply not find the right way to put a Boolean value in the if conditional.  Any help would be appreciated.

    None of the conditions in your earpiece supposed button functions.  you are always doing something like:

    hitcolor_rake = true

    {if (hitcolor_rake)}

    .

    ,

    }

    which means the conditional is always true.  If that is indeed what you want, there is no need for the conditional, just use:

    hitcolor_rake = true

    .

    .

    the next number is the code after the function.  It runs only once, when the playhead enters that context, until you click anybutton.  If you want the code to execute after the click of a button, you must put this code in a function and call from each of your listener functions button:

    function button_yellow_rakeclick(event:MouseEvent):void {}

    hityellow_rake = true;

    button_green_rake. Enabled = True

    button_blue_rake. Enabled = True

    button_purple_rake. Enabled = True

    button_orange_rake. Enabled = True

    button_red_rake. Enabled = True

    button_yellow_rake. Enabled = False

    gotoF();

    }

    function gotoF (): void {}

    If (hittriangle_rake == true & hitgreen_rake == true) {}

    gotoAndPlay (40)

    } else {}

    Stop()

    }

    }

  • Several buttons in Flash CS6

    I have problems with several buttons, get the error "1021 double function Defintion.

    I need to have at least 5 buttons at once and they need to reach a specific image.

    Y at - it a tutorial out there for this using CS6?

    It says error you named multiple functions with the same name.  Functions must be named uniquely.

Maybe you are looking for