Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / October 2006



Tip: Looking for answers? Try searching our database.

Naming a MovieClip from FlashVars

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mrGarvin - 17 Oct 2006 12:00 GMT
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 - 17 Oct 2006 14:02 GMT
use
_level0.roomNr to access the variables
mrGarvin - 18 Oct 2006 16:21 GMT
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 - 24 Oct 2006 01:36 GMT
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

> Nope... won't work.
>
[quoted text clipped - 5 lines]
>  So, I know that the script itself works. The movieclip changes color... BUT
> why won't it read in my FlashVars?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.