all groups > flash actionscript > november 2004 >
You're in the

flash actionscript

group:

Loading Variables


Re: Loading Variables Ben Dewey
11/18/2004 4:41:38 PM
flash actionscript:
In order to load from a text file
------------------------------------------------------------------
[data.txt]
myVarA=123&myVarB=Something

then in the script you could use:
loadVariablesNum("data.txt", 0);
_root.myVarA // is not available


If you are using HTML you can also use
----------------------------------------------------------------------
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
width="100%" height="100%" id="gallery" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="gallery.v3.swf" />

<param name="FlashVars" value="myVarA=123&myVarB=something" />

<param name="quality" value="high" />
<param name="bgcolor" value="#9cc76d" />
<embed src="mySwf.swf" quality="high" bgcolor="#9cc76d" width="100%"
height="100%" name="mySwf" align="middle" allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

If you use this one you don't have to call any loadVariablesNum commands:
_root.myVarA // is there by when loaded.


usually a good idea on frame one to say:
if (_root.myVarA == undefined) _root.myVarA = defaultVal;

Hope this helps! njoy!


[quoted text, click to view]

Re: Loading Variables Ben Dewey
11/18/2004 4:42:52 PM
correction:

_root.myVarA // is not available

should be
_root.myVarA // is now available

minor mistake completly changed the meaning, sorry about that.

[quoted text, click to view]

Loading Variables goodcookn
11/18/2004 9:16:13 PM
Hi all, I?m sure this is super easy but i couldn't find the awsner so here
goes. I?m trying to load a variable from a text file that will control the
position of my movie clip. Right now I have an array with MC to make a slider
and buttons controlling the position of the MC. I want to be able to change
which section you see first on loading. Here?s a link to what it looks like
now so you get any idea of what I'm talking about. Many thanks!
http://13tenths.com/xposed/my_slidemenu.html
Re: Loading Variables ufitzi
11/18/2004 9:31:50 PM
Try using the LoadVars object.

var lv = new LoadVars();
lv.load("file.txt",lv);

From here you need to wait until the variables are available.
There are many ways, but a common "timeline" solution is to put an action on a
frame (let's say 10), testing for your variable (if var ==
undefined){gotoAndPlay(5)}
This will loop until your var is available.

Also see loadVariables, it avoids the creation of an object (LoadVars)

Re: Loading Variables goodcookn
11/18/2004 9:57:36 PM
That didn't work for me...here's my code that work when i call the variable
from the button. --on frame 1 fscommand ('allowscale', false); var xPositions
= new Array(0,-200,-400,-600,-800,-1000); // this is an array for storing the
positions of the slider function jumpTo (number) { slider.newX =
xPositions[number]; } the 'jumpTo' is called on the button...and the (x)
relates to the position of the 'slider' MC on (press) { _root.jumpTo(0); }
So I want to be able to simulate the button code but on the first frame of my
move and be able to read a number to make the slider MC to move to that
position. Confused yet?? Thanks for the help!
AddThis Social Bookmark Button