PDA

View Full Version : Adding parameters to dynamically created movie clips?


05studios
11-06-2007, 06:56 PM
Hey guys, I found this page that explains how to pass variables to dynamically created clips, but I need to know how to do i with AS3.0 using this:


var entry1:tourDate = new tourDate();
addChild(entry1);


I need to pass the following variables to that entry1:

tourDate_str = "November 5, 2007"
tourTime_str = "8PM";
tourVenue_str = "Whatever";

Anyone?

Thank you!

senocular
11-06-2007, 07:07 PM
what page and pass how? Are those properties of the tourDate class?

ryryguy
11-06-2007, 07:42 PM
The syntax for doing what you want looks like this:

entry1.tourDate_str = "November 5, 2007"
entry1.tourTime_str = "8PM";
entry1.tourVenue_str = "Whatever";

The dot syntax there means "property inside the thing to the left of the dot".

That may not be the end of the story, however, depending on whether or not "tourDate" is a dynamic class. Here is a livedoc page explaining what a dynamic class is: http://livedocs.adobe.com/flash/9.0/main/00000046.html

If that seems like gobbledegook, don't despair. Just remember that MovieClip is a dynamic class, and any movie clip symbols you make through the Flash tool are dynamic classes. In any case, if "tourDate" is a dynamic class, then you are done. You can arbitrarily add new properties to a tourDate object using that dot syntax.

If "tourDate" is a class defined in a custom .as file, it's probably not dynamic. (It's dynamic if the word "dynamic" is just before the "class tourDate" in the declaration.) In that case "tourDate_str", "tourTime_str", and "tourVenue_str" must be public properties declared in the tourDate class. If they are not, then the compiler will complain when it encounters the assignment code shown above. The file will not compile.