Help with OOP flash

  • Arkitus
  • Novice
  • Novice
  • Arkitus
  • Posts: 17

Post 3+ Months Ago

Hello,

I'm new to this forum, but i'm sure you'll help me out! Atleast i think...

Ok, here's my question:

I have duplicated a movieclip like this:

Code: [ Select ]
duplicateMovieClip("dot", name, level);


where name and level are variables fed into the function.

now how can i set a new variable for the new movieclip?

what i mean is this:

Code: [ Select ]
name.xpos = 100;


But obviously this doesn't work. Can anyone help me out?

Thanks in advance!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Code: [ Select ]
this[name].xpos = 100;

name is a variable, a string variable. To reference the movieclip created with that variable you must place the variable inside this[name] , _root[name] , or _parent[name] so the variable will be evaluated to the name of a movieclip/object.

Make note, if you're passing names like "_root.contain.newName" to this function using this[name] will still evaluate it though it will be invisible to Flashs' actionscript debugger.
  • Arkitus
  • Novice
  • Novice
  • Arkitus
  • Posts: 17

Post 3+ Months Ago

Thanks for the fast reply.

I'm in school right now so i haven'y checked it, but im sure it works! ;)

Thanks again.

BTW, my site is http://www.arkitus.com
  • Arkitus
  • Novice
  • Novice
  • Arkitus
  • Posts: 17

Post 3+ Months Ago

Hi,

I just got home and checked it. It works!

Amazing! Thanks!
  • Arkitus
  • Novice
  • Novice
  • Arkitus
  • Posts: 17

Post 3+ Months Ago

Hi,

another problem: it works fine when the objects are created in the stage, but this doesn't work:

Code: [ Select ]
function letter(self:String, before:String, selfnumber:Number)
{
    duplicateMovieClip("letter", self, getNextHighestDepth());         // Create an instance of the dot
    
    this[name]._x = 500;
}
  1. function letter(self:String, before:String, selfnumber:Number)
  2. {
  3.     duplicateMovieClip("letter", self, getNextHighestDepth());         // Create an instance of the dot
  4.     
  5.     this[name]._x = 500;
  6. }


NOTE: this piece of code is in a movieclip called portinfo.

this piece of code doesnt position it to 500. can you help me out please?

thanks
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Code: [ Select ]
this[self]._x = 500;

duplicateMovieClip("letter", newName, getNextHighestDepth());
would be this[newName]._x
duplicateMovieClip("letter", newerName, getNextHighestDepth());
would be this[newerName]._x

Basically whatever the name of the variable that is the second paramater in duplicateMovieClip() is what you will put inside this[variable]


If you ever decide to use a string in that second paramater then you need to use that string in this["string"] as well.

var NHD = getNextHighestDepth();
duplicateMovieClip("letter", ("newerName"+NHD), NHD);
this["newerName"+NHD]._x
  • Arkitus
  • Novice
  • Novice
  • Arkitus
  • Posts: 17

Post 3+ Months Ago

oh thanks man!

I found out: i was using name instead of self ( typo )

thanks for pointing it out! 8)

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 11 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.