objectEvents

  how can an object receive startmovie/stopmovie events while travelling through a series of scriptless movies?
oop startmovie event scriptless_movie




  objectEvents
>Geoff Hoffman wrote:
>
>> the question is, how can a pre-birthed script object get a startMovie,
>> idle, or stopMovie event instead of a stage or movie object? this is
>> proving to be much more difficult than i originally thought...
>

Hi Jeff,

to let your pre-birthed scriptobject get idle, stopMovie etc events you will 
need a movieScript in all the individual movies which works like the one Owen 
recommended. However, there is no need to manually paste this into every single 
movie, you can create (and erase, if want to) the script on the fly.
Below is a parent script which on birth loads a scripttext from a field into 
a property. If a reference to this object is appended to the actorlist the 
object will check regularly whether a movie script exists or not, and create 
the movie script if needed. 


append the actorlist,new(script "vsObj")


The movie script will receive and redirect events like "stopmovie", "idle" etc.
This won't work for "prepareMovie", "startMovie" since the movie script for 
a new movie won't exist when those events happen.

HTH



--vsObj parent script

property myTicks,myWait
property myScriptName,myScriptTxt

on new me
  init me
  makeGlobal me
  return me
end

on makeGlobal me
  global gObj
  set gObj = me
end

on init me
  set myTicks = the ticks
  set myWait = 60
  set myScriptName = "Main"
  if the number of member "ScriptText" < 1 then
    alert "could not load ScriptText"
  else
    set myScriptTxt = the text of member "ScriptText"
  end if
end

on stepFrame me
  if the ticks > myTicks then
    checkForTheScript me
    set myTicks = the ticks + myWait
  end if
end

on checkForTheScript me
  if the number of member myScriptName < 1 then 
    set dScript = new (#script)
    set the name of dScript = "main"
    set the scripttext of dScript = myScriptTxt
  end if
end


on eraseScriptMember me
  if the number of member myScriptName > 1 then
    erase member myScriptName
  end if
end

on stopMovie me
  -- eraseScriptMember me
  put "StopMovie"
end

on mouseDown me
  put "mouseDown"
end


--field "ScriptText", 
-- the object above will load the scripttext from this field
-- expand this according to your needs

on stopmovie
  global gObj
  stopmovie gObj
end

on mouseDown
  global gObj
  mouseDown gObj
end


Home shock + cgi Bits 'n pieces Director Lingo Shocklets Contact










pageID=l_objectEvents