# Controlling a movie clip dynamically from mySQL

**URL:** <https://forum.kirupa.com/t/controlling-a-movie-clip-dynamically-from-mysql/182851>\
**Category:** Uncategorized\
**Created:** [March 21, 2006, 11:35pm UTC](https://forum.kirupa.com/t/controlling-a-movie-clip-dynamically-from-mysql/182851 "2006-03-21T23:35:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkalexander](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@rkalexander](https://forum.kirupa.com/u/rkalexander)\
**Post date:** [March 21, 2006, 11:35pm UTC](https://forum.kirupa.com/t/controlling-a-movie-clip-dynamically-from-mysql/182851/1 "2006-03-21T23:35:10Z")

</div>

I have a movie clip with 11 frames containing 10 different images named “thermometer”. I have a dynamic text box on the root of the movie with the var name of “therm”

action script in MC “thermometer”=

onEnterFrame = function() {  
if ((therm \<= 15000) && (therm \>= 0)){  
gotoAndStop(2);  
} else if ((therm \<= 30000) && (therm \>= 15000)) {  
gotoAndStop(3);  
} else if ((therm \<= 45000) && (therm \>= 30000)) {  
gotoAndStop(4);  
} else if ((therm \<= 60000) && (therm \>= 45000)) {  
gotoAndStop(5);  
} else if ((therm \<= 75000) && (therm \>= 60000)) {  
gotoAndStop(6);  
} else if ((therm \<= 90000) && (therm \>= 75000)) {  
gotoAndStop(7);  
} else if ((therm \<= 105000) && (therm \>= 90000)) {  
gotoAndStop(8);  
} else if ((therm \<= 120000) && (therm \>= 105000)) {  
gotoAndStop(9);  
} else if ((therm \<= 135000) && (therm \>= 120000)) {  
gotoAndStop(10);  
} else if (therm \>= 135000) {  
gotoAndStop(11);

}

the “therm” var will be populated through mySQL and PHP. what am i missing in my action script?

---

<div class="post-metadata">

**Author:** ![rkalexander](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@rkalexander](https://forum.kirupa.com/u/rkalexander)\
**Post date:** [March 21, 2006, 11:54pm UTC](https://forum.kirupa.com/t/controlling-a-movie-clip-dynamically-from-mysql/182851/2 "2006-03-21T23:54:21Z")

</div>

anyone?

does it have something to do with not using \_root or \_parent wehn calling on the variable “therm”?

---

<div class="post-metadata">

**Author:** ![gvozden](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/gvozden/32/1084_2.png) [@gvozden](https://forum.kirupa.com/u/gvozden)\
**Post date:** [March 21, 2006, 11:58pm UTC](https://forum.kirupa.com/t/controlling-a-movie-clip-dynamically-from-mysql/182851/3 "2006-03-21T23:58:11Z")

</div>

first, if therm is textfield then value that is entered in textfield is therm.text  
if you want to convert it to number use Number(therm.text)

second, this multiple if’s doesn’t lead anything  
if you are into something like that use switch command  
but here you can produce mathematic formula to get to the right frame

```auto
onEnterFrame = function() {
        // so therm can be equal this
       thermT = Number(_root.therm.text);
	frame = 1 + Math.floor(thermT / 15000);
	_root.gotoAndPlay(frame);
	// if you can have number higher than 150000 for therm and still want to set 11 as higher number use one if like 
	// if (frame>11) { frame = 11};
}

```

---

<div class="post-metadata">

**Author:** ![rkalexander](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@rkalexander](https://forum.kirupa.com/u/rkalexander)\
**Post date:** [March 22, 2006, 12:15am UTC](https://forum.kirupa.com/t/controlling-a-movie-clip-dynamically-from-mysql/182851/4 "2006-03-22T00:15:49Z")

</div>

```auto
onEnterFrame = function() {
        // so therm can be equal this
       thermT = Number(_root.therm.text);
    frame = 1 + Math.floor(thermT / 15000);
    _root.gotoAndPlay(frame);
    // if you can have number higher than 150000 for therm and still want to set 11 as higher number use one if like 
    // if (frame>11) { frame = 11};
}

```

[/quote]

wow this looks cool.  
the problem still is that textbox with the “therm” variable assiagned is on the root. I am trying to control the frame with a MC on the root.

so would it really be: “\_root.gotoAndPlay(frame);” ???  
woudln’t that control the root timeline and not the movie clip that i am trying to control?

---

<div class="post-metadata">

**Author:** ![gvozden](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/gvozden/32/1084_2.png) [@gvozden](https://forum.kirupa.com/u/gvozden)\
**Post date:** [March 22, 2006, 12:22am UTC](https://forum.kirupa.com/t/controlling-a-movie-clip-dynamically-from-mysql/182851/5 "2006-03-22T00:22:40Z")

</div>

ok  
replace \_root with mc name
