From: Rules for using loadvariables for html?
#1
Posted 08 October 2006 - 02:28 PM
I'm wanting to store message text (simple hypertext, to be exact) for a SWF in an html document so that I can change it without having to re-export the SWF each time I want to update the message.
I see a lot of discussions about some of the fine points of loadvariables, but I'd like to find a resource that walks me through the entire act of sucking an html document into a SWF.
Anyone know of such a resource?
Muy appreciado.
#2
Posted 08 October 2006 - 03:59 PM
Before we get into loading variable we have to cover a bit about Flat Files themselves and variable naming practices in external flat files.
Flat File Types -
When you start off it's best to use Notepad (not word or work pad as they do not produce flat file types) and use .txt
When you save the file Type = UTF (not ansi)
Variables and Expressions in .txt
The ampersand& defines the portion that is the variable name
Quote
It also is helpful to close the expression with an ampersand as otherwise when loaded the file may be searched thinking the string is incomplete. In Swishmax we refer to strings as text expressions while many programming languages refer to them as strings.
So we have two var names in our .txt document each with there own text value.
Available Methods
There are several methods to load variables. Dependent
Upon swf version for output and usage.
loadVariables();
loadVariablesNum(,0);
loadVars()
SendAndLoad()
LoadXML()
Of these the easiest to get aquainted with are
loadVariables();
loadVariablesNum(,0);
Both available via add script Movie Control
The difference between the two
[indent]loadVariablesNum(,0); Is intended for loading vars into the _root level
loadVariables(); is intended to load variables into a sprite or targeted object
[/indent]
When you use any of these actions you need to define
your event be it a frame event or a button event On Press for example[/]
The next portion is the url from whence the variables are loaded from.
"htttp://yoursite.tld/yourfile.txt"
eg
onFrame (1) {
loadVariablesNum("http://yoursite.tld/yourfile.txt",0);
}
When using a sprite to load the variables you need to define the sprite name (and the sprite has to exist)
onFrame (1) {
MySprite.loadVariables("http://yoursite.tld/yourfile.txt");
}
You will want some timeline frames for the file to load.more to come[/i]
#3
Posted 08 October 2006 - 04:19 PM
Dynamic Text Boxes
Dynamic text can be targeted or not. The difference between the two is that when a dynamic text box is targeted swishmax wraps a sprite around the object. Be it targeted or not a dynamic text box needs a name.
If it is not targeted the name of the text box can be the same as the variable name you wish to load. When the text box is targeted you have to associate the dynamic text box with a variable. This is done via the advanced tab. Also on the Advanced tab
you'll see a little return hook meaning text wrap Hint Use it or else your text may run off the text box unseen
The text boxes lines define the actual displayed area of your text. If your text exceeds the lines you can use text.scroll (although a bit stiff)
more
#4
Posted 08 October 2006 - 04:51 PM
Simply put you would need to create some sprites.
Brian Ayers Tutorial explains text.scroll rather nicely.
http://www.swishzone.com/index.php?area=re...amp;link_id=196
Font Types
Font types boil down to two Device and Embeded you can use both. However not at the same time.
Embeded
Embedded fonts allow you to use any font on your computer and all visitors will see the font however
-The overall file size will be larger because the entire font set needs to be embedded in the movie.
-Rich html type text is not achieveble
On the plus site the font can easily be used when a mask is present.
Device
With device fonts it can be a challenge to have the text in a masked sprite
The device font accesses the persons machine font system just like good old html
your choices are _sans, _serif and _typerwriter.
With device fonts you can use htmlText. While formating text in this manner can seem like a wonderful thing.. the flash player is very strick on what it considers html text and what is not. If the code is broken or not to flashplayer standard the visitor will see nothing. Render as html or htmltext does not alllow for non text html such as div's tables and the like.
Also you will not see the text rendered as html when you test in swishmax you will need to export to see the results
Sample swi to come shortly....
#5
Posted 08 October 2006 - 10:10 PM
and should be pinned.
Bernd
aka
#6
Posted 09 October 2006 - 07:24 AM
That was above and beyond. I really appreciate your help. That was a terrific. And you replied immediately. I went to bed thinking I'd check back in a couple of days. But you whooped on it right away.
Thank you so much.
#7
Posted 09 October 2006 - 07:27 AM
LOL
Attached Files
#8
Posted 19 October 2006 - 07:10 PM
Michael Chrysler, on Oct 8 2006, 10:27 PM, said:
LOL
Hi,
Further to what you've explained, how can I use the loaded variables in a script?
I have created a simple swf which has a dynamic text field in a sprite. I load in a text file with a variable which is the same as the text field's. I would now like to manipulate the variable in a script. I have the object.variable and the eval() methods but I get the message 'cannot find function or variable.
Any ideas?
Kz
#9
Posted 19 October 2006 - 07:25 PM
khanyz, on Oct 19 2006, 10:10 AM, said:
Further to what you've explained, how can I use the loaded variables in a script?
I have created a simple swf which has a dynamic text field in a sprite. I load in a text file with a variable which is the same as the text field's. I would now like to manipulate the variable in a script. I have the object.variable and the eval() methods but I get the message 'cannot find function or variable.
I think this is a question of knowing when the variables have loaded. Is there a way to test for this? Alternately, can I use the LoadVars class in SWISHmax? I tried but it's not recognised.
Any ideas?
Kz
#10
Posted 20 October 2006 - 08:08 PM
concetation? Look under File>Sample>swishlibs
For concetation your dynamic text would not have the same name as your imported variable name... (also see attached swi'
LoadVars can work however will not work in the swishmax environment directly.
This is becase swishmax is limited to running swf4 internally (loadvars wasn't supported in 4)
In order to test you will need to export first.
Attached Files
#11
Posted 05 December 2006 - 10:47 AM
http://forums.swishz...showtopic=20882
davidp
http://blog.swishzone.com/ ...for cool tutorials, samples and new components
#12
Posted 25 July 2007 - 08:44 AM
That's great MC, cleared up a lot of stuff for me, though I still have a problem with line returns not working...
[quote name='Michael Chrysler' post='179339' date='Oct 8 2006, 07:59 AM']Hi,
Before we get into loading variable we have to cover a bit about Flat Files themselves and variable naming practices in external flat files.
[size=3]Flat File Types - [/size]
When you start off it's best to use Notepad (not word or work pad as they do not produce flat file types) and use .txt[/quote]
I still don't know what you mean by 'flat' files... That said, I had to wipe my Notepad as it was infected, & can't find how to reinstall it,
[quote]When you save the file Type = UTF (not ansi)
[size=3]Variables and Expressions in .txt[/size]
The ampersand& defines the portion that is the variable name[/quote]
so I went via Word & saved under 'Encoded text' - UTF-8, which seemed to work - got all my European accents etc.
[quote]It also is helpful to close the expression with an ampersand as otherwise when loaded the file may be searched thinking the string is incomplete.
[size=3]Available Methods[/size]
There are several methods to load variables. Dependent
Upon swf version for output and usage.
loadVariables();
loadVariablesNum(,0);
loadVars()
SendAndLoad()
LoadXML()
Of these the easiest to get aquainted with are
loadVariables();
loadVariablesNum(,0);
Both available via add script Movie Control
The difference between the two
[indent]loadVariablesNum(,0); Is intended for loading vars into the _root level[/quote]
For some reason loadVariablesNum [/indent]didn't work for me... Maybe because my sprite is a level down from root?
[quote][indent]loadVariables(); is intended to load variables into a sprite or targeted object[/indent]
When you use any of these actions you need to define
your event be it a frame event or a button event On Press for example[/quote]
I'm using onFrames with setLabels (events triggered from an external swf)
[quote]The next portion is the url from whence the variables are loaded from.
"http://yoursite.tld/yourfile.txt"[/quote]
Mine's a local, relative URL...
[quote]eg
[/quote]
Couldn't get loadVariablesNum working...
[quote]When using a sprite to load the variables you need to define the sprite name (and the sprite has to exist)
You will want some timeline frames for the file to load.[/quote]
Not sure what you mean by this, but the MySprite.loadVariables option seems to work for me. Each string is loaded to a 'Labeled' frame, using [indent][/indent] etc., and naming the textboxes _1, _2, _3 etc. (though for static textboxes, the 1, 2, 3 form seemed to work fine; making them Dynamic added the underscore automatically...)
[quote]Also on the Advanced tab
you'll see a little return hook meaning text wrap Hint Use it or else your text may run off the text box unseen[/quote]
This is where I'm still bogging down! - I presume that's the little right-to-left arrow in the rectangle in the square between '***' and '../' ...Not sure when it's on or off, but it seems to make no difference either way. The text box is big enough because I had the text as static inside it before. It just doesn't do a line return, whether I've got one in the txt file or not.
#13
Posted 25 July 2007 - 09:35 AM
Numeric values can't be used for target names (sprite, text) or variable names which is why the underscore is used when you try to use a numeric value.
When the loadvariable request is recieved all the variables from that document are loaded in.
It may be easier to reassign the output via a button.
on (release) {
MyDynamicTextVar=loadedVar1;
}
#14
Posted 14 January 2012 - 07:19 PM
}
onFrame (1) {
loadVariablesNum("http://sprayberry.tripod.com/poems/lion.txt",0);
this.loadVariables("http://sprayberry.tripod.com/poems/lion.txt");
}
#15
Posted 15 January 2012 - 08:17 AM
Please review Variables and Expressions in .txt
Your text is not prepared properly so the movie can find it.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












