Wednesday, 15 August 2012

actionscript 3 - Calling certain functions whitout having the right arguments -



actionscript 3 - Calling certain functions whitout having the right arguments -

i have 2 function on as3 program, 1 fires when width , height changes:

stage.addeventlistener(event.resize, resizelistener); function resizelistener (e:event):void { //some commands }

and sec 1 fires 1 number of milliseconds pass:

var mytimer:timer = new timer(clockupdate, 0); mytimer.addeventlistener(timerevent.timer, updatedata); mytimer.start(); function updatedata(e:timerevent):void { trace("autoupdate"); trace(e); }

i need fires function manually, lets when user press button, don't know parameters have send them when called manually.

i tried resizelistener() , updatedata() of course of study fails asking me parameter.

you can create parameters in function optional providing default value. illustration taking 2 functions above , making event parameters optional:

function resizelistener(e:event = null):void { //some commands }

and

function updatedata(e:timerevent = null):void { trace("autoupdate"); trace(e); }

calling, example, resizelistener() execute function , value of e default null.

actionscript-3 flash

No comments:

Post a Comment