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

Get a Variable in url

Contributor ,
Nov 02, 2008 Nov 02, 2008

Copy link to clipboard

Copied

Hi all,

I have a small problem, but it seems that I can't figure it out by the help that there's out there.

Here's what I have... I'm making a website that has information about outboard engines... each one is read to Flash by an XML file, wich is exported by a MySQL database... so far so good.

I have a SWF that reads the XML and makes a grid with all engines, and gives each one a single ID number. When I click on one of them, a second window opens with a different SWF... also so far so good :)

The problem is, I want to catch the engine ID with the second window, when it opens.
When I click on the first one I send a request like the code below.
When this window opens I want catch the ID, so that I can show complete information on this engine particularly.

Thanks for the help.
TOPICS
ActionScript

Views

487

Translate

Translate

Report

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

LEGEND , Nov 02, 2008 Nov 02, 2008
With AS3 you get at the variables by looking at loaderInfo.parameters. It returns an object, which you can then look for the variable you're interested in, If "vars" is an object variable, and "id" is the one you're interested in, you can do this:

var vars:Object=this.loaderInfo.parameters;
trace(vars.id);


Votes

Translate

Translate
LEGEND ,
Nov 02, 2008 Nov 02, 2008

Copy link to clipboard

Copied

With AS3 you get at the variables by looking at loaderInfo.parameters. It returns an object, which you can then look for the variable you're interested in, If "vars" is an object variable, and "id" is the one you're interested in, you can do this:

var vars:Object=this.loaderInfo.parameters;
trace(vars.id);


Votes

Translate

Translate

Report

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 ,
Nov 02, 2008 Nov 02, 2008

Copy link to clipboard

Copied

By the way, that script would be on a main time line frame. The "this" refers to the main time line, which is where those AS2 _root variables end up in AS3.


Votes

Translate

Translate

Report

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
Contributor ,
Nov 02, 2008 Nov 02, 2008

Copy link to clipboard

Copied

Hi Colin,

Thanks for the suggestion... it worked, altough I have some considerations that might be useful for someone:

This solution works, and althought I would expect that the variable could be read right from the URL, it did not. I had to add the "FlashVars" to the HTML/PHP <embed> tag.
I put (flashvars="<?php echo ('id='.$_REQUEST['id']);?>") as a parameter of Flash.
In this way, the solution works.

Does it work for you, directly from the URL? (I'm using XAMMP as the local server).

Besides this, I was banging my head on the table because I wanted to trace the input, and you have to send the result to a dynamic text box, or the trace command wont work because you need this in a server. Well the dynamic text box didn't show anything because of the text font :S
I was using "Vrinda" text font...

Thanks for the Help, now I can go on 🙂

Votes

Translate

Translate

Report

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
Contributor ,
Nov 02, 2008 Nov 02, 2008

Copy link to clipboard

Copied

Hi Colin,

Thanks for the suggestion... it worked, altough I have some considerations that might be useful for someone:

This solution works, and althought I would expect that the variable could be read right from the URL, it did not. I had to add the "FlashVars" to the HTML/PHP <embed> tag.
I put (flashvars="<?php echo ('id='.$_REQUEST['id']);?>") as a parameter of Flash.
In this way, the solution works.

Does it work for you, directly from the URL? (I'm using XAMMP as the local server).

Besides this, I was banging my head on the table because I wanted to trace the input, and you have to send the result to a dynamic text box, or the trace command wont work because you need this in a server. Well the dynamic text box didn't show anything because of the text font :S
I was using "Vrinda" text font...

Thanks for the Help, now I can go on 🙂

Votes

Translate

Translate

Report

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 ,
Nov 02, 2008 Nov 02, 2008

Copy link to clipboard

Copied

LATEST
The technique I showed works for the url, flashvars, or swfobject. Not sure why you would see different results in each case.


Votes

Translate

Translate

Report

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