Groups | Blog | Home
all groups > flash data integration > october 2006 >

flash data integration : Naming a MovieClip from FlashVars


mrGarvin
10/17/2006 12:00:00 AM
I have a Flash file containing a floor plan over my office. I want visitors to
be able to locate the room for a specific person by clicking on the room nr.

In my HTML-code I give the FlashVars a value equal to the chosen person's room
number like this:
[b]<param name="FlashVars" value="roomNr=G207" />[/b]
Then I have the script in my Flash file where I first declare a variable
fetching the value from my FlashVars:
[b]myRoom = roomNr;[/b]
After that I have the code to produce a different color to a movieclip, thus
indicating which room it is:
[b]import flash.geom.ColorTransform;
var myCT:ColorTransform = new ColorTransform();
myCT.rgb = 0x009900;[/b]

I have made a movieclip for each room and named their instances like the
values that will be passed when selecting a room. For instance: G207, F106E,
U123 and so on.
My idea here is to let the instance name of a movieclip be the value from my
FlashVars which I declared earlier. So I wrote the next line:
[b]myRoom.transform.colorTransform = myCT;[/b]

BUT... this will not work. I have tried two things to understand the problem:
1. I put a dynamic text field on stage, naming it and assigning its text to be
the value from FlashVars:
[b]testTextField.text = roomNr;[/b]
And it works perfect. It gets the correct value and writes it out on stage.
2. I tried to hard code the myRoom variable to be equal to G207 (myRoom =
G207; ), and that works fine as well.

WHY won't it recognise my FlashVars value as an instance name of a movieClip?

Any ideas anyone?`
AnandMX
10/17/2006 1:02:09 PM
use
mrGarvin
10/18/2006 3:21:16 PM
Nope... won't work.

Nothing happens. Tried to use _level0. both on the variable myRoom
(_level0.myRoom) and the incoming FlashVars (_level0.roomNr) but no reaction.

The movieclip instance won?t change color... only when I hardcode the variable
to be: myRoom = G207
So, I know that the script itself works. The movieclip changes color... BUT
why won't it read in my FlashVars?
John
10/23/2006 5:36:13 PM
Hi,

It is possible that this is a scope issue (as AnandMX indicates).

My approach to debugging this problem would be as follows:

1) Insert trace() statements in key areas to quickly see the values of
variables
Example:
trace("myRoom = " + myroom);
trace("this.myRoom = " + this.myRoom);

2) Experiment with scope:
a) myRoom
b) _level0.myRoom
c) this.myRoom (note: you probably know, but I'd suggest this
syntax**)
d) _parent.myRoom
e) _root.myRoom (note: when using _root you need to use lockRoot =
true)

3) Try setting a local variable to the loadVars value and use trace()
Example:
var XX:String;
XX = myRoom;
trace("XX = " + XX + ", myRoom = " + myRoom);

Hope this gives you some ideas,
--JK

[quoted text, click to view]
AddThis Social Bookmark Button