Flash AS ?
- Started
- Last post
- 16 Responses
- Luckypp
I have set a variable on the main timeline, such as size = 100;
How do I access that variable from within a movie clip?
_root. variable value?
- Luckypp0
bumpity bump
someone must know this
- Rand0
also, how many seconds do I need to buffer a streaming mp3 for?
- imakedesign0
you can get a global var .. so you can access it from anywhere
- Luckypp0
Ok, with the global variable, what is the syantax to get that value?
- colag0
view this for syntax etc.
http://livedocs.macromedia.com/f…
- joyride0
on the main timeline you set a var mySize = "100";
then from withing the movieClip you, which is on the main timeline, you can call it like:
textBox = _parent.mySize
results will be textBox = "100"
Think of the movieClip as an object and the var is not in that object, but above it, so _parent. if you have a movieclip within that movieclip it would be _parent._parent and so on. Make sense? are you trying to get a string (some text)? or set a number (maybe to set the size of something)?
- unfittoprint0
don't use _root
use this._parent._parent . . .
[& cuz Flash8's lockroot is bad for your health]
Rand, it depends of the mp3 itself, its size and encoding. Usually flash preloads just [after the sound object's start()] the right amount to allow a flawless stream until the end.
Unfortunately it's not an exact science and it always depends of the server and users system specs...
- Luckypp0
I probably wasn't as clear as I should have been. I am just writing a variable that will be a set value. Such as
valuename = value#, not actually using mySize.
And then, when an action it preformed it checks the setProperty of a MovieClip and adjusts it accordingly to the variable value set.
I think reading the Macromedia LiveDoc will help me out.
And, I love using _root. to target to my MovieClips, what's bad about it?
Thanks all for the help!
- unfittoprint0
everything works fine when using _root in a 'standalone' swf.
now imagine that same swf will be externally loaded into a parent swf file.
the _root will 'belong' tareget its parent's _root instead of the loaded movieclip stage.
therefore the usage of this._parent... will make your code modular, capable of being integrated in a larger structure without compromise.
- unfittoprint0
where
the _root will 'belong' tareget its parent's _root instead of the loaded movieclip stage.
read
the _root will now target its parent's _root instead of the loaded movieclip stage.
- Luckypp0
Huh, I use _root to call to loaded movies all the time, can make for some long calls at times, but seems to work just fine for me.
I see that ._parent can be more efficient, but what I am usually doing is controlling multiple loaded movies from one nav on the main timeline so _root. works great for me.
Thanks for the info though, I'll try it out.
- unfittoprint0
imagine this:
you make a calendar fla. it works fine by itself, checking all the stage variables 8months, weekdays, etc...] using _root.
now you would like to add that same file to every future project just by using loadMovie and positioning it in the stage.
Unfortunately the calendar cannot find its variables anymore, because it target the parent's Stage [the new _root] instead of its own.
- Luckypp0
Oh yeah I see the application of ._parent and it looks slick, just not what I need at the moment.
Also, I see how to write a global variable, but who do you read it?
- jpea0
same way. eg:
myClip._x = _global.myXvaralso, i found this a while back and have liked how it works regarding long _parent's
- Luckypp0
Thanks!!!
- joyride0
listen to unfit. drop the _root now, its bad practice. the sooner you get it the better.
Unfit sounds like we've had similiar experience with the _root thing. I've had to reDo a project that took 1.5 months because 2 years later they wanted to use it in something else, no longer stand alone. That was boring!