Deprecated ActionScript Code, new code for linking flash to pdf? -


i'm using flash pro. cs5 actionscript 3, , i've never worked flash before, , i've searched while way , continuously syntax errors code. saw asked similar question, , person said code deprecated, can assume since mine looks similar deprecated. flash i'm trying make button open pdf file. code have right is;

on(release){     geturl("index dividers.pdf"); } 

and syntax error keeps saying 'expecting semicolon before left brace' stupid may sound, added semicolon before left brace, , 1 error turned 3 errors, didnt solve anything. know proper code open pdf file? appreciated!

geturl has been replaced navigatetourl, works accepting urlrequest object. in case, looks this:

navigatetourl(new urlrequest('index dividers.pdf')); 

as click handler, can't on(action) notation anymore, event based now. need set listener on target, , assign handler function called when event fires:

this.addeventlistener(mouseevent.click,clickhandler);  function clickhandler(evt:mouseevent):void {     navigatetourl(new urlrequest('index dividers.pdf')); } 

a bit more events:

firstly, event. event can thought of message object broadcasts when action has occurred. 1 we're using here mouseevent.click. resolves string 'onclick', stored in mouseevent class, don't worry details now. object broadcast event when user clicks mouse. other mouse events include mouseevent.mouse_over , mouseevent.mouse_out. there other events kinds of things, , can create own.

now listeners. in order know when event has been dispatched object, add listener object. using example above, we'll break down:

this.addeventlistener - we're saying want listen event coming targeted object. have changed in code target button instance, perfect.

(mouseevent.click, - event want listen for.

clickhandler); - function called result of event being detected.

so need function we've named handler (the second parameter addeventlistener. function must accept 1 argument, event object. reference actual instance of event dispatched, , mouse event typecast mouseevent. in above example didn't have use object, must still have in function declaration or flash not compile.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -