Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 12:58 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Can you clone a clone?
PostPosted: June 22nd, 2008, 6:11 pm 
Offline

Joined: March 24th, 2008, 5:03 pm
Posts: 5
I'd like to clone a cloned object. Can it be done? I've tried:

Code:
var cloneAgain = this.CloneObject()


but it doesn't work.

Thanks[/code]


Top
 Profile  
 
 Post subject:
PostPosted: June 22nd, 2008, 10:09 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Yes you can. I'd post the IMP but my upload quota is at max :-(

Basically, the first clone takes the name of the object and is affixed with .2147483648

Normally if you clone the object again it is affixed with 2147483649 (one more) but in the case of cloning the clone - the clones name becomes affixed so it would read:

.2147483648.2147483649

Calling this.CloneObject() from a script object on an action attached to the clone will work fine.

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: June 23rd, 2008, 7:25 am 
Offline

Joined: March 24th, 2008, 5:03 pm
Posts: 5
I tried to do this. I associated the original textbox with a trigger "Mouse Down" and action Script - "var foo=this.CloneObject()"

When the page loads, the textboxes are cloned. However, when I do the MouseDown thing, nothing happens.


Top
 Profile  
 
 Post subject:
PostPosted: June 23rd, 2008, 11:30 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Without seeing an example, I'd have to guess that the clone works fine except you are not repositioning the clone and thus it's simply appearing over the top of the original object.

Try this:

var pos = this.GetPosition()

this.CloneObject(pos.x,pos.y,true)

Which will place the clone on top of the cloned object.

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: June 23rd, 2008, 12:41 pm 
Offline

Joined: February 26th, 2005, 2:44 pm
Posts: 58
Interjection...

Quote:
I'd post the IMP but my upload quota is at max


Well, I think your quota needs to be extended.

_________________
http://www.akidsheart.com
http://www.storyit.com


Top
 Profile Visit website  
 
 Post subject:
PostPosted: June 23rd, 2008, 2:09 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Thank Roxie,

But I think it already was - but I must have uploaded too many EXEs in the past.

It's probably worth these being removed as they were just samples and not really useful.

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: June 23rd, 2008, 10:21 pm 
Offline

Joined: March 24th, 2008, 5:03 pm
Posts: 5
Unfortunately, that still doesn't seem to be working... Here is my code for the function when I'm setting things up. The textbox which needs to be cloned is called "word"

Code:
function getWords()
{
   word.SetSelection(0,-1)
   word.ReplaceSelection(w[0])
   word.Show()
   var theFile = OpenFile(WORDFILE)
   var x=0
   var rx=125
   var ry=340

   while (theFile.EndOfFile() == false)

   {
      w[x] = theFile.ReadLine()
         var col = String.random(COL) // picks a random number between 0 and COL for text colour
         cloneWord = word.CloneObject(rx,ry,true)
//         cloneWord.Show()
         cloneWord.SetSelection(0,-1)
         cloneWord.SetColour(c[col])
         cloneWord.ReplaceSelection(w[x])
//         cloneWord.SetPosition(rx,ry,0)
      
         rx+=75
         if (rx>450)
         {
            ry=ry+35
            rx=120
         }
         x++
         NUM_WORDS = x
   }


On the object "word", I select the trigger MouseDown and call the script action where I have tried your suggestions... It's beginning to drive me crazy and I know I've done something stupid :x :D [/code]


Top
 Profile  
 
 Post subject:
PostPosted: June 23rd, 2008, 11:08 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
If you are calling this function from the object then it will ONLY EVER clone the original object "word"

cloneWord = word.CloneObject(rx,ry,true)

The cloned object is not called "word"!

You need to pass the object being cloned to the function and not hard code the name. Use;

getWord(this)

In the function use a parameter to receive the object and use this in place of the hard coded name.

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: June 25th, 2008, 7:20 pm 
Offline

Joined: March 24th, 2008, 5:03 pm
Posts: 5
That makes total sense. :oops: However, I'm still stuck! I set a trigger for On Show to do the action script getWords(this) and my function is now called:
getWords(theWord) where theWord is my object to clone.

However, I keep getting into an infinite loop. I know that it's probably because every time the clone is cloned it triggers the function getWords(this) but I haven't a clue what to do!


Top
 Profile  
 
 Post subject:
PostPosted: June 25th, 2008, 8:14 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
1st - cheers DW for upping the upload limit - I'm including a simple IMP that shows the cloning of the clone.


2nd - Yes using an on show trigger will cause a loop :-). Simplest solution don't use on show. Keep the original textbox hidden and create the first clone by calling the getWords function at the start of the script ensuring that the cloneobject command is set to show the clone.

Mack


You do not have the required permissions to view the files attached to this post.

_________________
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: June 25th, 2008, 10:05 pm 
Offline

Joined: March 24th, 2008, 5:03 pm
Posts: 5
Fantastic! Thanks for all your help. 8)


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 5 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