# Simple but frustrating

**URL:** https://forum.kirupa.com/t/simple-but-frustrating/58491
**Category:** Uncategorized
**Created:** [July 22, 2004, 10:03pm UTC](https://forum.kirupa.com/t/simple-but-frustrating/58491 "2004-07-22T22:03:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![DaDeViL](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@DaDeViL](https://forum.kirupa.com/u/DaDeViL)
#### Post date: [July 22, 2004, 10:03pm UTC](https://forum.kirupa.com/t/simple-but-frustrating/58491/1 "2004-07-22T22:03:05Z")

</div>

ok i have this very simple code in my button

```auto

on (press) {  	
trace(this.the_state);
_root.content_box.morph(this.the_state, this.the_content);  
}

```

the trace gives me the result i need, but when i plug this.the\_state into the  
function morph, it does not respond at all…also if i do this:

```auto
on (press) { 
 _root.content_box.morph("full", this.the_content);  
}

```

it works perfectly the way it needs to…am i doing something wrong that is very obvious in the first code block?  
This is frustrating me because it seems so simple and straightforward, since that trace lets me know im inputting the right kind of value…  
Thanks

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 1:54am UTC](https://forum.kirupa.com/t/simple-but-frustrating/58491/2 "2004-07-23T01:54:14Z")

</div>

We can’t help until you show us the morph function…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 3:03am UTC](https://forum.kirupa.com/t/simple-but-frustrating/58491/3 "2004-07-23T03:03:04Z")

</div>

sorry, here it is:

```auto

function morph(requested_state, content_sent) { 
trace(requested_state); //this gives the correct result
trace(current_state); //this gives teh correct result
content = content_sent;  	
if (current_state != requested_state) {  		
if ((current_state == "lefthalf") && (requested_state == "full")) { gotoAndPlay(2);  		
} else if ((current_state == "full") && (requested_state == "righthalf")) 
{ gotoAndPlay(11);  		
} else if ((current_state == "righthalf") && (requested_state == "full")) { gotoAndPlay(21);  		
} else if ((current_state == "righthalf") && (requested_state == "lefthalf")) { gotoAndPlay(21);  		
} else if ((current_state == "lefthalf") && (requested_state == "righthalf")) { gotoAndPlay(40);  		
} else if ((current_state == "full") && (requested_state == "lefthalf")) { gotoAndPlay(52); }  
	
} else {  		
get_content(current_state);  	
}  
}

function get_content(state) {
	tellTarget (_root.content_box.contentText) {
		gotoAndStop(state);
	}
	_root.content_box.contentText.scrollerText.htmlText = content;
}

```

as i commented, the traces in teh above code give the expected result

here is a link:  
dead link

click through the testbuttons to see how morph works  
(testbuttons states from left to right are: “lefthalf”, “full” and “righthalf”)

so here is what i am trying to do…im getting alll the content for teh site thru xml, and from this xml content i dynamically create all teh buttons i need and then display the content…to do this i duplicate a movie clip and then assign it variables like so:

```auto

_root.menu["button"+n].title = title; 
// where title is from my xml i sent to flash

_root.menu["button"+n].the_state= state; 

```

where teh title is the title of the button…as u can see that all works and i can get whatever content i need too – but i need to assign one more variable and here is where the problem comes in…i need to assign each new movie clip a ‘state’ also so that white content box can ‘morph’…i wrote the function and it all works fine if i dont send the state variable through the xml and hard code it in like i described earlier

as soon as i do this:

```auto
on (press) {    
 _root.content_box.morph(this.the_state, this.the_content);
    }

```

it all stops working

if i trace this.the\_state right before i use the morph function, it prints  
"lefthalf", “full” or “righthalf” respectively

Thanks

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 26, 2004, 10:33pm UTC](https://forum.kirupa.com/t/simple-but-frustrating/58491/4 "2004-07-26T22:33:47Z")

</div>

ok after some tracing, I figured out that the main if-loop in the function function does not work

```auto

if ((this.current_state == "lefthalf") && (requested_state == "full")) { trace("--1---");  			
gotoAndPlay(2);  		
} else if ((this.current_state == "full") && (requested_state == "righthalf")) { trace("--2---");...

```

It doesnt print anything even with the correct values for requested\_state and current\_state … only if i call morph like:

```auto

morph("full", this.content)

```

Thanks

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 27, 2004, 8:23pm UTC](https://forum.kirupa.com/t/simple-but-frustrating/58491/5 "2004-07-27T20:23:40Z")

</div>

anyone?
