Changeset 186 for trunk/lingosource/castlib2/commonMovieScript.ls
- Timestamp:
- 09/17/08 20:50:38 (4 years ago)
- File:
-
- 1 edited
-
trunk/lingosource/castlib2/commonMovieScript.ls (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lingosource/castlib2/commonMovieScript.ls
r184 r186 1 1 -- commonMovieScript 2 -- was anderes3 2 ----------------------------------- 4 3 -- CREATED: … … 6 5 -- 7 6 -- DESCRIPTION: 8 -- Shared Global Handlers ©03 Alex da Franca -- alex@farbflash.de7 -- Shared Global Handlers c03 Alex da Franca -- alex@farbflash.de 9 8 -- ------------------------------------------------------------------- 10 -- these handlers are shared between all of my scripts Alex da Franca ©2003 alex@farbflash.de9 -- these handlers are shared between all of my scripts Alex da Franca c2003 alex@farbflash.de 11 10 -- for private use of my scripts -> poor documentation -> use at own risk ;-) 12 11 … … 1203 1202 on mGetInstance me, instName, useRawNew 1204 1203 1204 if ilk(instName) = #string then instName = symbol(instName) 1205 1205 1206 theGlobs = mGetGlobalList(me) 1206 1207 gParentScriptInstances = theGlobs.getaprop(#gParentScriptInstances) … … 1214 1215 if ilk(saveScr) = #instance then return saveScr 1215 1216 1216 if mGetMemType(me, member( instName)) = #script then1217 if useRawNew = 1 then saveScr = rawnew(script instName)1218 else saveScr = new(script instName)1217 if mGetMemType(me, member(string(instName))) = #script then 1218 if useRawNew = 1 then saveScr = rawnew(script string(instName)) 1219 else saveScr = new(script string(instName)) 1219 1220 gParentScriptInstances.setaprop(instName, saveScr) 1220 1221 return saveScr … … 1223 1224 if saveScr = -1 then return 0 1224 1225 gParentScriptInstances.setaprop(instName, -1) 1225 inst = mGetXScript( symbol(instName))1226 inst = mGetXScript(instName) 1226 1227 if not(listP(inst)) then 1227 1228 if ilk(inst) = #instance then inst = inst.script … … 1255 1256 1256 1257 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 1257 -- xxxxxxxxxxxxxxxxxx reloada stored script instance:1258 1259 on m ReloadInstance me, instName1258 -- xxxxxxxxxxxxxxxxxx delete a stored script instance: 1259 1260 on mDeleteInstance me, instName, dontCallDestroyHandler 1260 1261 theGlobs = mGetGlobalList(me) 1261 1262 gParentScriptInstances = theGlobs.getaprop(#gParentScriptInstances) 1262 1263 1263 if ilk(gParentScriptInstances) <> #proplist then exit 1264 1264 if dontCallDestroyHandler <> 1 then 1265 saveScr = gParentScriptInstances.getaprop(instName) 1266 if ilk(saveScr) = #instance then call(#mDestroy, [saveScr]) 1267 end if 1265 1268 gParentScriptInstances.deleteprop(instName) 1269 end 1270 1271 1272 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 1273 -- xxxxxxxxxxxxxxxxxx reload a stored script instance: 1274 1275 on mReloadInstance me, instName, useRawNew, dontCallDestroyHandler 1276 mDeleteInstance me, instName, dontCallDestroyHandler 1277 return mGetInstance(me, instName, useRawNew) 1278 end 1279 1280 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 1281 -- xxxxxxxxxxxxxxxxxx replace a stored script instance: 1282 1283 on mReplaceInstance me, instName, scriptInstance, dontCallDestroyHandler 1284 if not(objectP(scriptInstance)) then exit 1285 theGlobs = mGetGlobalList(me) 1286 gParentScriptInstances = theGlobs.getaprop(#gParentScriptInstances) 1287 if ilk(gParentScriptInstances) <> #proplist then exit 1288 if dontCallDestroyHandler <> 1 then 1289 saveScr = gParentScriptInstances.getaprop(instName) 1290 if ilk(saveScr) = #instance then call(#mDestroy, [saveScr]) 1291 end if 1292 gParentScriptInstances.setaprop(instName, scriptInstance) 1266 1293 end 1267 1294 … … 1860 1887 end 1861 1888 1889 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 1890 -- the naming convention used throughout all my movies for names, filename etc.: 1891 -- Names must be only alphanumeric chars and the underscore and should not start with a number 1892 -- As a rule of thumb: every string which can be made into a symbol is valid. 1893 1894 on mValidateName me, str 1895 if ilk(str) <> #string then return 0 1896 if length(str) < 1 then return 0 1897 if "0123456789" contains char 1 of str then return 0 1898 return string(symbol(str)) = str 1899 end 1862 1900 1863 1901 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx … … 1957 1995 end 1958 1996 1997 1998 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 1999 2000 on mFormatdate me, theFormat, theDate 2001 theFormat = string(theFormat) 2002 if length(theFormat) < 1 then theFormat = "yyyy/mm/dd" 2003 if ilk(theDate) <> #date then theDate = the systemdate 2004 2005 offs = offset("y", theFormat) 2006 if offs > 0 then 2007 ende = offs+1 2008 repeat while char ende of theFormat = "y" 2009 if ende > length(theFormat) then exit repeat 2010 ende = ende+1 2011 end repeat 2012 len = ende - offs 2013 if len < 3 then theYear = char 3 to 4 of string(theDate.year) 2014 else theYear = string(theDate.year) 2015 put theYear into char offs to offs + len -1 of theFormat 2016 end if 2017 2018 theFormat = mReplaceCharWithNumber(me, theFormat, "m", theDate.month) 2019 2020 theFormat = mReplaceCharWithNumber(me, theFormat, "d", theDate.day) 2021 2022 return theFormat 2023 end 2024 2025 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2026 2027 on mReplaceCharWithNumber me, theString, theChar, theNumber 2028 offs = offset(theChar, theString) 2029 if offs > 0 then 2030 ende = offs+1 2031 repeat while char ende of theString = theChar 2032 if ende > length(theString) then exit repeat 2033 ende = ende+1 2034 end repeat 2035 len = ende - offs 2036 theNumber = string(theNumber) 2037 repeat while length(theNumber) < len 2038 put "0" before theNumber 2039 end repeat 2040 put theNumber into char offs to offs + len -1 of theString 2041 end if 2042 return theString 2043 end 2044 1959 2045 -- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 1960 2046
Note: See TracChangeset
for help on using the changeset viewer.
