How do you add a sort of "Back" button
to Page1 so that it will close itself
(so that we are back to the main
screen)?
There are many ways of doing this. You could just hide the page by setting it's visibility to false, you could just move it off stage so that it can't be seen or you could remove the movieclip altogether (along with probably other options). Basically it's completely up to you and you must choose the best option to suit your purposes.
In your example you want page1.swf to have a button that, when clicked on, tells it's parent to do something. I would personally recommend that this happens by dispatching an event when the button is clicked. The parent can then listen to page1 for that event. When it catches that event, you can then choose what to do with page1.
I suggest you have a read of some articles regarding events in actionscript 3 to find out how this is achieved. Try this one for starters
If Page1 were a movie, is it possible
to automatically close it after it
finishes playing?
Yes this is also possible and again i would use the same method as stated above. Dispatch an event on the final frame (or when at least you know the final frame has been hit) that tells it's parent to do something.
Tracking it down
At first I thought this was a coercion bug where null
was getting coerced to "null"
and a test of "null" == null
was passing. It's not. I was close, but so very, very wrong. Sorry about that!
I've since done lots of fiddling on wonderfl.net and tracing through the code in mx.rpc.xml.*
. At line 1795 of XMLEncoder
(in the 3.5 source), in setValue
, all of the XMLEncoding boils down to
currentChild.appendChild(xmlSpecialCharsFilter(Object(value)));
which is essentially the same as:
currentChild.appendChild("null");
This code, according to my original fiddle, returns an empty XML element. But why?
Cause
According to commenter Justin Mclean on bug report FLEX-33664, the following is the culprit (see last two tests in my fiddle which verify this):
var thisIsNotNull:XML = <root>null</root>;
if(thisIsNotNull == null){
// always branches here, as (thisIsNotNull == null) strangely returns true
// despite the fact that thisIsNotNull is a valid instance of type XML
}
When currentChild.appendChild
is passed the string "null"
, it first converts it to a root XML element with text null
, and then tests that element against the null literal. This is a weak equality test, so either the XML containing null is coerced to the null type, or the null type is coerced to a root xml element containing the string "null", and the test passes where it arguably should fail. One fix might be to always use strict equality tests when checking XML (or anything, really) for "nullness."
Solution
The only reasonable workaround I can think of, short of fixing this bug in every damn version of ActionScript, is to test fields for "null" and
escape them as CDATA values.
CDATA values are the most appropriate way to mutate an entire text value that would otherwise cause encoding/decoding problems. Hex encoding, for instance, is meant for individual characters. CDATA values are preferred when you're escaping the entire text of an element. The biggest reason for this is that it maintains human readability.
Best Answer
use misch's preprocessor ... it supports macros as well ...
greetz
back2dos