on(release) {…} or myButton.onRelease = function() {…} - action script 2 issues

北城余情 提交于 2019-12-07 22:28:10

问题


I am having real confusion with some flash banners I'm creating and making the button into a clickable object which opens a web page.

I have been using this code for a while below, which works...

on(release){
    getURL("http://www.the-dude.co.uk", "_blank");
}

And I placed this code on actual button within the actions panel


However I have been told the code above is very old and that I should use action script like below...

buttonInstance.onRelease = function() {
    getURL("http://www.the-dude.co.uk", "_blank");
}

So I've tried to get this method below to work but nothing happens when I click the button, and I get one error, this...

So in a nutshell I cannot get this newer code to work! Ahh


Can anyone please help me understand where I am going wrong?

I have tried placing the new code in the Scene 1 of my actions. No worky..

And I've also tried placing the code below, actually on my button within the actions panel...

this.onRelease = function() {
    getURL("http://www.the-dude.co.uk", "_blank");
}

Still not working.


My scene settings are alway this...


Any help would be great thanks.


回答1:


You need to place the code below on the same timeline as the instance of the button (as you tried). And the instancename of the button must be "buttonInstance".

You can set the instance name in the properties panel when the button is selected.

buttonInstance.onRelease = function() {
    getURL("http://www.the-dude.co.uk", "_blank");
}


来源:https://stackoverflow.com/questions/12689817/onrelease-or-mybutton-onrelease-function-action-script-2-iss

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!