Converting HTML to Work as Actionscript in Flash

Posted on 2006-03-20
Last Modified: 2010-04-03
I have HTML from mapquest that allows users to get directions to a specific loaction.  How do I convert the below HTML  to work in a Flash file as actionscript?

<form action="" method="get">
<div align="center">
<input type="hidden" name="go" value="1">
<input type="hidden" name="2a" value="">
<input type="hidden" name="2c" value="">
<input type="hidden" name="2s" value="">
<input type="hidden" name="2z" value="">
<input type="hidden" name="2y" value="">
<table border="0" cellpadding="0" cellspacing="0" style="font: 11px Arial,Helvetica;">
<tr><td colspan="2" style="font-weight: bold;"><div align="center"><a href=""><img border="0" src="" alt="MapQuest"></a></div></td></tr>
<tr><td colspan="2" style="font-weight: bold;">FROM:</td></tr>
<tr><td colspan="2">Address or Intersection: </td></tr>
<tr><td colspan="2"><input type="text" name="1a" size="22" maxlength="30" value=""></td></tr>
<tr> <td colspan="2">City: </td></tr>
<tr> <td colspan="2"><input type="text" name="1c" size="22" maxlength="30" value=""></td></tr>
<td> ZIP Code:</td></tr>
<tr><td><input type="text" name="1s" size="4" maxlength="2" value=""></td><td>
<input type="text" name="1z" size="8" maxlength="10" value=""></td></tr>
<tr><td colspan="2">Country:</td></tr>
<tr><td colspan="2"><select name="1y"><option value="CA">Canada</option><option value="US" selected>United States</option></select></td></tr>
<tr> <td colspan="2" style="text-align: center; padding-top: 10px;"><input type="submit" name="dir" value="Get Directions" border="0"></td></tr>
<input type="hidden" name="CID" value="lfddwid">

I also have other code to convert into actionscript.  This code allows me list a stock price of a company.  How can I use this code in Flash??

function go()
  dim xml, text
  Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
  xml.Open "GET", "", False
  xml.Send ""
  text = xml.ResponseText
  If Len(text) > 0 Then
    go = text
    Response.Write "404 - File not found..."
  End If
  Set xml = Nothing
end function

dim quote, columns, i
columns = Array("Symbol","Last Trade","Date","Time","Change")
quote = split(replace(go(),chr(34),""),",")

<table cellpadding="0" cellspacing="0" width="250">
<td class="stockheading" align="center" valign="bottom" width="40">Symbol</td><td class="stockheading" align="center" valign="top" width="40">Last<br>Trade</td><td class="stockheading" align="center" valign="bottom" width="45">Change</td><td class="stockheading" align="center" valign="bottom" width="70">Date</td><td class="stockheading" align="center" valign="bottom" width="55">Time</td>
<td valign="top" class="stock">
<table cellpadding="0" cellspacing="0">
<td class="stock" align="center" width="40"><%=quote(0)%></td><td class="stock" align="center" width="40"><%=quote(1)%></td>

<% dim plusminus %>
<% plusminus = trim(quote(4)) %>

<% if Left(plusminus, 1) = "-" then %>
<td class="stockred" align="center" width="45"><%=quote(4)%></td>
<% else %>
<td class="stockgreen" align="center" width="45"><%=quote(4)%></td>
<% end if %>

<td class="stock" align="center" width="70"><%=quote(2)%></td>

<% dim pmam %>
<% pmam = Right(quote(3), 2) %>
<% pmoram = Ucase(pmam) %>
<% pmsorams = Replace(quote(3), pmam, " " & pmoram) %>

<td class="stock" align="center" width="55"><%=pmsorams%></td>
Question by:mikesandra
    LVL 19

    Expert Comment

    You will not be able to use most of that code inside of flash.

    All you can do is try to do work arounds with components and variables. Based on the value of the variable, you can send the user to a different url. Html in flash is limited pretty much to the basic tags <a>, <b>, <p>, <ul>, <u>, <li>, etc... Check out help for a complete list.

    So, after all that, you would only have the choice of duplicating the functionality in flash, but it won't be by use of translating html. Sorry to be the bearer of bad news.


    Author Comment

    Well, since this is a 500 point question can someone help me to figure out how I can incorporate this into actionscript and make it work?
    LVL 19

    Expert Comment

    mikesandra, the points are not important, because it cannot be done. However, if there's something particular effect you're trying to achieve, then please describe that, and I, or one of us, will help you with it.


    Author Comment

    What I am trying to achieve are 2 things.  I want to be able to have a user type in their starting address and they click submit and it brings them into a mapquest page with the directions to a specific location.

    The other thing I want to do within Flash as show a stock price 20 minutes delayed.  Is this something someone can help me with?
    LVL 19

    Accepted Solution


    Consider the following: It looks difficult, but it is not.

    These are directions from a fictitious location in Florida to another.
    All you have to do is collect the address city state and zip from the user and substitute the entries above in a getURL statement. so would put on a button:
    getURL("" +  myAddress + "&1c=" + myCity    .... and so on.

    If you'll notice, mapquest wants plus signs instead of spaces in your street, for example. Also, you would have to complete the rest of the text by using the destination address. This is accomplished in very much the same way, except it is easier because you can pre-code the destination, if that is your goal.

    Unfortunately, I don't have anything for you on your second question.

    Author Comment

    Let me play with this.  I'll let you know how it turns out.

    Author Comment


    I created a form and a submit button in Flash so they can connect with Mapquest.  I want what the user types into field 1a to get passed to the getURL function.  Something like this.

    getURL(""+1a+"&1c=Oakland&1s=NJ&1z=07436&dir=Get+Directions&CID=lfddwid", "_blank");

    But its not working.  I get the following error;

    Scene=Scene 1, Layer=Basic Info, Frame=1: Line 2: ')' or ',' expected
         getURL(""+1a+"&1c=Oakland&1s=NJ&1z=07436&dir=Get+Directions&CID=lfddwid", "_blank");

    Scene=Scene 1, Layer=Basic Info, Frame=1: Line 3: Unexpected '}' encountered

    I don't know what I'm doing wrong.  Can you help me?
    LVL 17

    Expert Comment


    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
    This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
    The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
    The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now