Attaching and retrieveing data with instance names?

By estberg | May 13, 2009

actionscript3

Hi,

My first post here at ActionScript.org! I’m quite new to AS3 so please bare with me :)

I’m developing an AS3 module where the user interacts with certain hardware. One part is highlighting the hardware’s features when the user hovers certain points on it. There’s quite a lot of work to be done here (about 6 modules with about 30 highlights each) so I figured I would make it as changeable as possible.

On the stage I’ve placed all instances of a movieclip that acts as the pointer for the highlights. This movieclip uses a class that animates it upon mouseover/mouseout (hence only two animation functions are required for them all). At the same time I want to display a unique text for every point, and this is where the trouble comes in.
I figured I could attach data with each instance to the class somehow, and then create a new text field upon accessing the class. This is what I came up with:

Code:

// Features
f1.name = "Växla mellan användnings- och viloläge.";
f2.name = "Display.";
f3.name = "Visa den elektroniska programguiden.";
f4.name = "Visa huvudmenyn.";
f5.name = "Lämna menyn.";
f6.name = "Infraröd sensor (för fjärrkontroll).";
f7.name = "Inspelningsindikator - lyser när inspelning pågår.";
f8.name = "Spela in.";
f9.name = "USB-anslutning för externt minne.";
f10.name = "Kortläsare till ditt programkort."


As you can see I tried using the instance property name to attach the data, it failed though (I didn’t get a compile error for this but I couldn’t retrieve the data in the class).
How would you approach this? Do I have to create a variable for each instance’s data, then match them (same number etc.)? Or is there a simpler way?

Thanks,
-Staffan

actionscript3

Please reply at our Forum

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

© 2007 ActionScript 3.0