07.12.2012 Views

Adobe Director Basics

Adobe Director Basics

Adobe Director Basics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ADOBE DIRECTOR BASICS<br />

Asynchronous programming<br />

property pNetID -- integer id of the net operation<br />

on mouseUp(me)<br />

me.mStartOperation()<br />

end mouseUp<br />

on enterFrame(me)<br />

if pNetID then<br />

me.mCheckProgress() -- calls mCompleteOperation() when done<br />

end if<br />

end enterFrame<br />

on mStartOperation(me)<br />

vFolder = "http://my.example.com/director/" -- use valid URL<br />

vURI = vFolder&"test.php?input=50"<br />

pNetID = getNetText(vURI)<br />

end mStartOperation<br />

on mCheckProgress(me)<br />

if netDone(pNetID) then<br />

me.mCompleteOperation()<br />

end if<br />

end mCheckProgress<br />

on mCompleteOperation()<br />

vNetError = netError(pNetID)<br />

case vNetError of<br />

"OK", "":<br />

vResult = netTextResult(pNetID)<br />

otherwise: -- an error occurred<br />

vResult = "Error: "&vNetError<br />

end case<br />

pNetID = 0<br />

alert vResult<br />

end mCompleteOperation<br />

If you want to experiment with postNetText(), you can use the following handler instead of the mStartOperation()<br />

handler above.<br />

on mStartOperation(me)<br />

vFolder = "http://my.example.com/director/" -- use valid URL<br />

vURI = vFolder&"test.php"<br />

vData = ["input": 50]<br />

pNetID = postNetText(vURI, vData)<br />

end mStartOperation<br />

PHP scripts are case sensitive. A PHP variable called ‘Input’ is not the same as a variable called ‘input’. This makes it<br />

risky to use symbols as the properties of the property list that acts as the second parameter for the postNetText() call.<br />

Try executing the following lines in the Message window to understand why.<br />

trace(#mixed) -- creates #mixed as a symbol with a lower-case "m"<br />

-- #mixed<br />

trace(string(#Mixed))<br />

-- "mixed"<br />

trace(string(#mixer)) -- built-in symbol with an upper-case "M"<br />

-- "Mixer"<br />

To avoid issues due to the case-sensitivity of PHP scripts, always use strings for the property names in the data property<br />

list sent with a postNetText() call, as shown in the example above.<br />

To test a postNetText() operation, complete with feedback to indicate that something is happening, download and<br />

launch the php.dir.<br />

Last updated 8/26/2011<br />

440

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!