View Full Version : importing variables and having graphics visible or not based on the variable
camax
06-12-2003, 08:20 AM
I am a newbie to the forum, so I apologize if I ask my question in the wrong area here...
Here is what I am trying to do. I have a map of a housing complex with all the plots of land. I want to be able to import data/variables (whether the plot of land is sold or available) into the Flash map and have a "sold" type of graphic either appear or not appear on each of the plots based on the outside data (in this case a php page.)
I've always been more on the visual design end of Flash, so adding all this developer type of language is newer to me, but very exciting. I know what I want to do above can be done, based on reading lots of sites, but as I have such minimal background in this so far, I really need a step by step type of approach for my learning curve. I've enjoyed the tutorials I've taken so far, and I know how to get variables into Flash with a text file and display them. So far I have been banging my head trying to get a visual representation to either be on or off based on the variable though. So here I am! Thank you if you can help me to understand this better!!
~Cam
Billy T
06-12-2003, 09:17 AM
not sure I really understand your problem
so you know how to get vars into flash...all you need to do is check the values and then set the _visible of a clip to true or false
eg
text file looks like
&showImage1=true&showImage2=false
and then in flash after the vars have load just use if statements such as
if(showImage1){
image1._visible=true;
}else{
image1._visible=false;
}
yeah?
camax
06-12-2003, 05:56 PM
Thank you Billy, that may be enough to get me started, or the answer itself. I will post again with the results of your suggestion.
To clarify, just in case...
I have a map which shows plots of land. I will be importing data that will indicate if each plot of land is still available or has been sold. If the plot is still available, the map will remain as is, and the overlaying "sold" graphic will NOT be visible. If the plot has been sold, the "sold" graphic will be visible.
So I believe the data will look like:
&plot1=available&plot2=sold&plot3=available
Getting the data into Flash is about as much as I've been able to execute successfully so far. I'm way down the learning tree on programming, so I'm hoping to learn if statements like you've suggested. I have assumed the best method is to make each plot of land its own movie clip, and then make the movie clip visible or not based on the incoming data.
Billy T
06-12-2003, 11:53 PM
yep...or make each plot a movieclip that has a blank first frame with a stop action, and then 2 frame labels that contain the different graphics
when the data is loaded in (use LoadVars btw) then you send each clip to a certain frame label
cheers
camax
06-19-2003, 08:06 PM
I have been banging my head for days now trying to get this to work.
I have a loop that seems to work, making sure all the variables are loaded before I try to use them.
The _visible code seems to work fine in the case or true and false, as in I can make things not be visible, but I can NOT seem to make objects be visible or not based on the data imported or even if I assign a variable straight in Flash to do so! How do I make a movie clip visible or not based on imported data? Here's what I did, and maybe someone can check my work?
=======================================
data in "text.txt" file:
lot1=sold&lot2=available&lot3=sold&lot4=available&EOF=true
=======================================
actions layer:
=<FRAME 1>=
loadVariablesNum("text.txt", 0);
=<FRAME 2>=
if (EOF == "true") {
gotoAndStop(4);
}
=<FRAME 3>=
if (EOF == "true") {
gotoAndStop(4);
} else {
gotoAndPlay(2);
}
=<FRAME 4>=
stop();
=======================================
example of actions assigned to movie clips "lot1sold" and "lot2sold":
onClipEvent (load) {
if (lot1 == "sold") {
_visible = true;
} else {
_visible = false;
}
}
onClipEvent (load) {
if (lot2 == "sold") {
_root.lot2sold._visible=true;
} else {
_root.lot2sold._visible=false;
}
}
=======================================
To me it seems like my "if" statements are not being checked. Movie clips are invisible by default, or if I flip the true and falses, clips are visible by default. Nothing I've tried seems to have the "if" statement condition met! Help please!
~Cam
Billy T
06-20-2003, 12:04 AM
your variables are being loaded into _level0 but you're not checking them there
need something like
onClipEvent (load) {
if (_level0.lot1 == "sold") {
_visible = true;
} else {
_visible = false;
}
}
cheers
camax
06-20-2003, 01:04 AM
THANK YOU SOOOO MUCH Billy!!! That did the trick all right. Good on you mate! Cheers! You really came through when I needed help bad. Thank you. Thank you. Thank you.
(I used to live in Canberra myself, but that is OT)
Billy T
06-21-2003, 01:15 AM
no worries
cheers
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.