Cloning
Where's my script gone?
Monday, May 21, 2007 by TwoWolves | Discussion: DesktopX
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
Reply #2 Monday, May 21, 2007 7:42 PM
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 Monday, May 21, 2007 10:53 PM
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 Tuesday, May 22, 2007 5:25 PM
- Sub Object_OnScriptEnter
- DesktopX.Object("Grid").OnTop
- NumGrids = DesktopX.Object("MaskFrame").Height
- FirstX = DesktopX.Object("Grid").Left
- FisrtY = DesktopX.Object("Grid").Top
- For i = FirstY + 1 To NumGrids - 1
- nameObj = "Grid" & i
- DesktopX.Object("Grid").Clone nameObj, FirstX, FisrtY + i
- DesktopX.Object(nameObj).Parent = DesktopX.Object("Browser1")
- DesktopX.Object(nameObj).OnTop
- DesktopX.Object(nameObj).Group = "Window"
- Next
- 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 Tuesday, May 22, 2007 5:54 PM
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 Wednesday, May 23, 2007 12:59 PM
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 Wednesday, May 23, 2007 1:14 PM
I have a nagging feeling that it's something simple that we're missing.
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!







Reply #1 Monday, May 21, 2007 6:42 PM
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.
Edit: Oh great now the code tags are stripping formatting?