Cloning

Where's my script gone?

Hi,

I have a script which clones an object in a loop a number of times, everything is fine except the original object contains a small script which reacts to mouse-enter events. However the cloned objects do not inherit the script.

Any ideas how to do this or what I'm doing wrong?

Help much appreciated.

- Wolfie

3,681 views 7 replies
Reply #1 Top
Lot's of ideas but, then your question can be interpreted a number of ways.

If the script is in the object that is being cloned then it should be working unless the mouse-enter event is referencing another cloned object?

For example this script would work in the cloned object the same as the base object.

Code: vbscript
  1. 'Called on mouse over object
  2. Sub Object_OnMouseEnter
  3. Object.Left + 10
  4. Object.Top + 10
  5. End Sub


Edit: Oh great now the code tags are stripping formatting?
Reply #2 Top
The OnMouseEnter only references that object.

So they are all independent objects that do not reference each other but are grouped (for movement) and have a third-party parent who does all the cloning.

Interestingly the object they are all cloned from reacts fine to the mouse events.


?
Reply #3 Top
If the have a parent object then they aren't independent objects. Since you have them grouped make sure the child setting is no within the summary tab. That may do the trick.

It's hard to be specific without knowing much about the actual script. I just ran my bar chart script which clones a group (all are child objects) plus they reference & update a hidden object on mouse over and the mouse over event works fine. I'm using the onstatechange(state) because I'm referencing functions in the base script for different states.

So, this leads me to believe it is either specifically tied to your relationships or a scripting issue.
Reply #4 Top
My Creation code is :
Code: vbscript
  1. Sub Object_OnScriptEnter
  2. DesktopX.Object("Grid").OnTop
  3. NumGrids = DesktopX.Object("MaskFrame").Height
  4. FirstX = DesktopX.Object("Grid").Left
  5. FisrtY = DesktopX.Object("Grid").Top
  6. For i = FirstY + 1 To NumGrids - 1
  7. nameObj = "Grid" & i
  8. DesktopX.Object("Grid").Clone nameObj, FirstX, FisrtY + i
  9. DesktopX.Object(nameObj).Parent = DesktopX.Object("Browser1")
  10. DesktopX.Object(nameObj).OnTop
  11. DesktopX.Object(nameObj).Group = "Window"
  12. Next
  13. End Sub

Each "Grid" Object has an OnMouseEnter block but only the original has the bespoke code, if I view the code for cloned objects they simply have a default script with empty OnScriptEnter and OnScriptExit sections.

Why don't they pick up the same script as the original object?

(Child setting is no)
Reply #5 Top
If you copy & pasted that code directly then the answer lies within in the code. It appears it's possibly a simple spelling mistake "FisrtY"?

Edit:
If "Grid" has Parent & Group already set then you don't need these two lines.

DesktopX.Object(nameObj).Parent = DesktopX.Object("Browser1")
DesktopX.Object(nameObj).Group = "Window"

Plus, since you have set the ontop setting to the object being cloned you may not need this line either.

DesktopX.Object(nameObj).OnTop
Reply #6 Top
You're right about the typo and not needing the parent and group being set in the script, however that hasn't resolved my problem.

The good news is that I have found a workaround.

By creating the clones in the outer-most object I can intercept the onmouseover messages using the *Ex form and determine the sender child object in an IF block.

Not as clean as I'd like but it works.

Thanks for your help though SirSmiley.
Reply #7 Top
No problem. Glad you found a solution.

I have a nagging feeling that it's something simple that we're missing.