问题描述:

I have this code on .fla file

fm_button.visible = false;

var menu_label:Array = new Array("Introduction", "Products", "Services",

"Testimonials", "Our Company", "Contact Us");

var total:Number = menu_label.length;

var i:Number = 0;

var page:Number;

var main_menu:MovieClip = new MovieClip();

stage.addChild(main_menu);

for (i = 0; i < total; i++)

{

var btn = new flashmo_button();

btn.name = "btn" + i;

btn.x = fm_button.x;

btn.y = fm_button.y + i * ( fm_button.height + 10 );

btn.buttonMode = true;

btn.item_no = i;

btn.flashmo_click_area.addEventListener( Event.ENTER_FRAME, btn_enter );

var each_substring:Array = menu_label[i].split("|");

btn.flashmo_button_label.fm_label.text = each_substring[0];

btn.item_url = each_substring[1];

main_menu.addChild(btn);

}

function btn_over(e:MouseEvent):void

{

e.target.parent.over = true;

}

function btn_out(e:MouseEvent):void

{

e.target.parent.over = false;

}

What i want is to get this values:

("Introduction", "Products", "Services", "Testimonials", "Our

Company", "Contact Us");

from a text or php file named menu.php or menu.txt

Is this possible?

网友答案:

Why you need read from .php file?

Is this client-server communication? In that case, when .fla file loads by client browser over http(s) you should do something like this:

menu.php (for example put this file to document root folder):

<?php $menu = array('Elem1', 'Elem2');
echo json_encode($menu); ?>

.fla:

var sendData:URLVariables = new URLVariables();

var request:URLRequest = new URLRequest('/menu.php');
request.method = URLRequestMethod.GET;

var loader:URLLoader = new URLLoader(request);
loader.addEventListener(Event.COMPLETE, onCompleted);

So, your .fla are doing query to server and get's list of categories (onCompleted method receive data).

If this is not server-client communication, you should use other file format, because .php is not a data storage )

相关阅读:
Top