一、概述 <BR />
When preloading a Shockwave movie, you usually want to do these things: <BR /> <BR />
(1) specify the URL of the thing to preload; <BR /> <BR />
(2) be told how the preload is progressing; <BR /> <BR />
(3) be told when the preload is complete. <BR /> <BR />
in Part 1 of this tutorial will be to create a generic "preloader" script which will preload a file from a specified URL. This preload might take a while, so we will create some sort of 'progress bar' to show the user how much more of their precious time will be required before the thing has finished downloading. <BR /> <BR />
In Part 2 of this tutorial will look at ways of creating animated progress bars. <BR /> <BR />
In Part 3, we will create similar scripts for submitting and retrieving text from a server using POST and GET. <BR /> <BR />
Part 4 looks at setting parameters for shockwave using the SW parameters in the Object (and Embed) HTML markup used to embed Shockwave. <BR /> <BR />
In Part 5, we'll look at some fairly common activities, such as getting and posting data to a MySQL database. <BR /> <BR />
<BR /> <BR />
<BR />
二、the preloader parent script <BR />
-------------------------- <BR />
--Preloader" Parent Script (v.1) <BR />
<BR />
property myNetID <BR />
<BR />
on new (me, netAddress) <BR />
myNetID = preloadNetthing(netAddress) <BR />
aTimerObj = timeout().new(me.string,100, #Timer_CheckProgress, me) <BR />
end <BR />
<BR />
on Timer_CheckProgress (me, aTimer) <BR />
finished = netDone(myNetID) <BR />
if finished then <BR />
put "All done!!" <BR />
aTimer.forget()--?????? <BR />
else put "Still downloading..." <BR />
end <BR />
---------------------------- <BR />
preloadnetthing()单独不能做什么事情,除了启动下载过程。为了查看 <BR />
下载情况,可以使用getStreamStatus(ID) 函数获得下载的字节数 <BR />
使用netDone(ID)查看网络操作是否完成。 <BR />
当然为了不时呼叫这些函数,使用timeout()objects是个很好的注意。 <BR />
上面的脚本(called "Preloader")
in message type:
--------------------
script("Preloader").new("http://www.lingoworkshop.com/dcr/ldr_test.dcr")
------------------
你注意到:new 脚本中,并没有返回参数 me
?======================
For an object to stay alive, there needs to be a persistent reference to the object somewhere - otherwise Director assumes it is no longer needed and removed is from memory (in a process called 'Garbage Collection' - see the Illustrated OOP Primer for more details). In this example, the timeout object keeps a reference to the object so we don't need to store another reference anywhere else.
?===================
If no targetObject is given, 就假定 the #timeoutHandler 在 movie script中
下一步 ,我们要把 this objec与其他 other objects结合。
|