Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Flash HTML javascript help !!!

Participant ,
Jun 25, 2012 Jun 25, 2012

Hi All,

I have 50 different images on my server, the images are loaded into the flash. and also i created a HTML page which i will use to show the images. Now in flash when the user click on a particular image, that image should be loaded into the HTML which we already have on the server. 

So i need to pass the name from flash to html to find the clicked image to show. also i want to hide the tool, status bar ... on the HTML. 

If it is possible to load the HTML on full-screen that will be great.

Here I have done something…

btnClipMc.addEventListener(MouseEvent.CLICK,onBtnClicked);

var address:String = ("two.html");

var URL_var:URLVariables = new URLVariables();

function onBtnClicked(evt:MouseEvent):void

{

                URL_var.query = inpTxt.text;

                var jscommand:String = "window.open('" + address + "','win','toolbar=no,scrollbars=no,location=no,status=no,menubar=no');";         

                urlReq:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);");

                urlReq.data = URL_var;

                navigateToURL(urlReq, "_self");

}

This is showing error message.

Can you help me to correct this script ? !!!

TOPICS
ActionScript
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Jun 29, 2012 Jun 29, 2012

I have done it .. !!!

// variable that you want to pass to the HTML

imageName = "image_1"

//making html restriction with query

var address:String = "'largeView.html?query =" + imageName;

                    //var jscommand:String = "window.open(" + address + "','win','width=1100, height=600, resizable=yes, toolbar=no,scrollbars=yes,location=no,status=no,menubar=no, left=0, right=0');";

//Final JS to trigger the HTML

var jscommand:String = "window.open(" + address + "','win','width="+finalWidth+", heigh

...
Translate
LEGEND ,
Jun 26, 2012 Jun 26, 2012

You really want to do this by writing a JS function in the html doc that holds your Flash movie and then calling that function using ExternalInterface.call()

In the head of the html doc, put something like this:

<script>

function showPhoto(thisPhoto)

{

window.open(thisPhoto,'win','toolbar=no,scrollbars=no,location=no,status=no,menubar=no') ;

}

</script>

Then, in your Flash movie, your function will look something like this:

function onBtnClicked(evt:MouseEvent):void {

     ExternalInterface.call("showPhoto",address);

}

    


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 26, 2012 Jun 26, 2012

Thanks for the great reply,

I understand something, you just passing the URL address to the "showPhoto" function. But can you tell me where do you pass the image name that will open on the new html ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2012 Jun 26, 2012

The second argument for the call function, ExternalInterface.call("showPhoto",address);

is address. That's your variable that holds the actual url that you want to show.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 26, 2012 Jun 26, 2012

Actually i need to open different images in single HTML. So the HTML name will be same but inside loading Image name will be keep changing. So how do you do that ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2012 Jun 26, 2012

If you mean that you want to write an actionscript function that will build an html page based on the actual photo that is selected, then you are going about this process in the wrong way. While you can write a document on the fly using javascript, you need to have a document in the browser on which to write. You could do this by writing a library of information on the html document that holds the flash movie or linking to a library that holds this information, essentially a bunch of javascript functions. Then call the appropriate function based on the photo selected.

A far simpler, and more useful method is to just make an individual html page for each photo and call the appropriate html document based on the photo selected.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 26, 2012 Jun 26, 2012

Dear Rob Dillon,


Photo will not be constrain, it can be increase. So individual HTML is not possible. Also thru actionscript its possible.


I heard that you can pass a query to the particular HTML from Flash using "window.open" function.


window.open('"+ address +"','win','toolbar=no,scrollbars=no,location=no,status=no,menubar=no');"


Here address will be our URL (second HTML) and you can pass a query within the URL. It would be like..


var address:String = ("imgeLoad.html?query ='"+image_1+"'");


But somewhere this script is struck. I am sure this can be done !!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 27, 2012 Jun 27, 2012

Ok, this is completely different from what you asked for the first time. If you have an empty html document, two.html, as you say in your first message, then there is no way in Flash to call that page and then have a new photo displayed on that page based on a user selection in the flash movie.

If you have an html document that can respond to a query string as you describe in your last message, then you will need a server side cgi of some sort, PHP or Perl perhaps to read and interpret the query string that you pass to it. If you have this sort of mechanism in place, then you don't need or want to use javascript to make that call. If this is the scenario that you are trying to use, then look at the online help section for URLVariables. There is an example that shows how to send variables to a server side cgi.

Is this what you are trying to achieve?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 29, 2012 Jun 29, 2012
LATEST

I have done it .. !!!

// variable that you want to pass to the HTML

imageName = "image_1"

//making html restriction with query

var address:String = "'largeView.html?query =" + imageName;

                    //var jscommand:String = "window.open(" + address + "','win','width=1100, height=600, resizable=yes, toolbar=no,scrollbars=yes,location=no,status=no,menubar=no, left=0, right=0');";

//Final JS to trigger the HTML

var jscommand:String = "window.open(" + address + "','win','width="+finalWidth+", height="+finalHeight+", toolbar=no,scrollbars=yes,location=no,status=no,menubar=no, left=0, top=0');";

//making URL request

var urlReq:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);");

//Calling HTML JS

navigateToURL(urlReq, "_self");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines