05-08-2004, 10:06 AM
|
#1
|
|
member
Join Date: Apr 2003
Location: France
Posts: 77
|
escaping ASCII characters >127 in FlashVars with php urlencode ?
HI,
I want to pass some variables generated by a php script to my flash file.
Theses variables are required as soon as the flash file launches, so I was thinking of passing them using the FlashVars parameter in the EMBED and OBJECT tags. The php script would write the parameters and urlencode their values.
I encounter this problem : this is a French website so the values could have some characters with ASCII values superior to 127 (such as "é"). Colin Moock tells that such characters should be coded in the format %xx%xx (when the Systeme.useCodepage is true).
But : php's urlencode encodes such values in the format %xx, which causes a wrong character to display in Flash.
So, I am considering instead to retrieve the values using loadvars and a php script that delivers the parameters needed, but I'd prefer to avoid it : I would have to pass with flashvars an identifyer that would be then passed from flash to the php script so this one knows what set of parameters it has to deliver.
May be there is another solution : to set the format of the HTML page to unicode. I am not sure, but may be it could avoir to escape the problematic characters in the FlashVars parameter?
Or, there is a way to keep the page in its coding, and manage to encode the characters with php in FlashVars ?
I am kind of lost to decide what to do... if anyone has precious information about this, thanks for posting !
_marabout_
|
|
|
05-08-2004, 10:34 AM
|
#2
|
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
|
Howdy...
This is what I think...
You are trying to transfer some characters via HTML and PHP is being translated into HTML as well, so you do not need to do any conversion by using urlencode() function... (I could be wrong though...)
Here is the PHP code...
PHP Code:
<?php
$str = "êáâãäåæçèéêëìêîïðñòóôõö÷øùúûüýþÿ";
?>
<HTML>
<HEAD>
<TITLE>testHighChars</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF" marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" RIGHTMARGIN="0" BOTTOMMARGIN="0" SCROLL="NO">
<!-- URL's used in the movie-->
<!-- text used in the movie-->
<TABLE WIDTH="100%" HEIGHT="100%" BORDER="0">
<TR align="center" valign="middle">
<TD>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
WIDTH=350
HEIGHT=100>
<PARAM NAME=FlashVars VALUE="chars=<?=$str?>">
<PARAM NAME=movie VALUE="testHighChars.swf">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="testHighChars.swf"
FlashVars="chars=<?=$str?>"
quality=high
bgcolor=#FFFFFF
WIDTH=350
HEIGHT=100
TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</EMBED>
</OBJECT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
and the AS is just this line to display the given FlashVars variable...
PHP Code:
this.chars_txt.text = _level0.chars;
|
|
|
05-08-2004, 10:51 AM
|
#3
|
|
member
Join Date: Apr 2003
Location: France
Posts: 77
|
Well I agree with you, it seems that it works without escaping these chars...
On the other side, Colin Moock says in Chapter 2 of "AS for Flash MX Def Guide" that variables passed via FlashVars should be url encoded, accordingly to the rules explained in the loadVars class of the book.
I though that he had good reasons to say so and concluded that not escaping may work under precise circumstances, but might fail in some others...
Pretty uncomfortable conclusion... What do you think ?
|
|
|
05-08-2004, 10:59 AM
|
#4
|
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
|
Well... The only problem is that if I add
$str = urlencode($str);
right below where I defined $str, I get nothing in the sample...
Can you tell me the page number so that I can look up my ASDG???
|
|
|
05-08-2004, 11:06 AM
|
#5
|
|
member
Join Date: Apr 2003
Location: France
Posts: 77
|
I have the French edition, so I am not sure the page number will help.
It's 2/3 pages before the end of chapter 2, the paragraph might name "Loading external variables".
|
|
|
05-08-2004, 03:43 PM
|
#6
|
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
|
Hm... I cannot find it... Are we talking about ASDG I???
|
|
|
05-09-2004, 03:42 AM
|
#7
|
|
member
Join Date: Apr 2003
Location: France
Posts: 77
|
About Moock's "ActionScript for Flash MX : the Definitive Guide, 2nd Edition" (in French)
|
|
|
05-09-2004, 11:08 AM
|
#8
|
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
|
That's what I have but I do not really see the part that goes with FlashVars in chapter 2...
(I've got to tell you that I never really read chapter 2 though... I just skipped that part when I first read the book...  )
|
|
|
05-09-2004, 11:26 AM
|
#9
|
|
member
Join Date: Apr 2003
Location: France
Posts: 77
|
You'd have impressed me if you had read the book from the very beginning until the last appendix...
I searched O'Reilly's website, there is actually a paragraph named "Loading external variables" at the end of chapter 2. At least it appears on the table of content on the website : http://www.oreilly.com/catalog/actscript2/toc.html
|
|
|
05-09-2004, 11:44 AM
|
#10
|
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
|
Ah... Now, I get it.. 
I got the first edition which has no mention of that part... Buaaaaa~~~~~
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 06:55 PM.
///
|
|