Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 10:09 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: How to reset the counter of cloned objects?
PostPosted: July 12th, 2009, 6:36 am 
Offline

Joined: March 4th, 2007, 7:17 pm
Posts: 132
I use the cloning method to display images of cards:

Code:
function clicksFull ()
{
var xPos = 580
var yPos = 670
myClone = new Array()
ImagePath = new Array()
for ( i = 1;i<s;i++)
{
myClone[i] = deck1.CloneObject(485,496)
myClone[i].SetPosition(xPos,yPos,0.1)
ImagePath[i] = deck + "\\" + i + ".jpg"
myClone[i].SetImage(ImagePath[i])
xPos = xPos + xRaz
yPos = yPos - yRaz
}
}


In order to obtain information about the card, I take the name of the object (myName = this.GetName()). All names of clones have the form: deck1.245367177, deck1.245367178, deck1.245367179 etc.

A problem, if I want to reload the page, the names of cloned objects continues. Even its removal with myClone[i].DestroyClonedObject() does not solve the problem. Reset resumed only when the publication closed.

Advise pls which way is better to solve this problem:
1. How does to count cloned objects without rebooting the publication?
Or 2. How to obtain a unique property of the cloned object, so i can get the information in the database.

_________________
Opus Pro 5.5
Win XP


Top
 Profile  
 
 Post subject:
PostPosted: July 12th, 2009, 9:19 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
You can't reset the clone counter without restarting.

As for a unique property, I'm not sure what you're after. As all page objects are destroyed, you would need to save and restore any customised properties of any object, not just clones, when switches pages.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: July 12th, 2009, 1:44 pm 
Offline

Joined: March 4th, 2007, 7:17 pm
Posts: 132
Hi Mack,
Thank you for your advice.

Perhaps I am not very understand the explanation:(

I have a number of identical cloned objects (I created its using the script above). Its all have different images - playing cards. I need to get when you click on the object value of the image (for example, the King of the Clubs). Values are in the database. I can make a request to the database, but how do I identify this object?

_________________
Opus Pro 5.5
Win XP


Top
 Profile  
 
 Post subject:
PostPosted: July 12th, 2009, 4:24 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
The is no unique id for clones that is persistent. Once destroyed it's not possible to get it back.

However, if you are creating 52 (for example) clones, one for each card, then you can at point of creation add a property that identifies the individual clone using a criteria set by you.

This DOES NOT mean that you can have a persistent value BUT every time you run your for loop the values will be allocated in the same order and thus the ordinal recall of any clone will be identical.

function clicksFull ()
{
var xPos = 580
var yPos = 670
myClone = new Array()
ImagePath = new Array()
for ( i = 1;i<s;i++)
{
myClone[i] = deck1.CloneObject(485,496)
myClone[i].SetPosition(xPos,yPos,0.1)
ImagePath[i] = deck + "\\" + i + ".jpg"
myClone[i].SetImage(ImagePath[i])
myClone[i].cardNumber = i
xPos = xPos + xRaz
yPos = yPos - yRaz
}
}

Simply use this.cardNumber to access the value when clicking on the object. Of course this is a simple version. You could link to an array containing the card name, suit.

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: July 12th, 2009, 5:29 pm 
Offline

Joined: March 4th, 2007, 7:17 pm
Posts: 132
Mack - you best ScriptMan! :D
Thank you!

This is the most simple and elegant solution that suits me.
And i have already started to calculate how many times and how much i have is created clones and subtract these amounts in order to find initial ID.

I need to buy JS manual... :)

_________________
Opus Pro 5.5
Win XP


Top
 Profile  
 
 Post subject: Re: How to reset the counter of cloned objects?
PostPosted: May 12th, 2011, 5:34 pm 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
Excellent, thanks for posting the solution here Mack. Using similar code to do something different.

Thanks.

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group