Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Extensions and Plugins > Components

Reply
 
Thread Tools Rate Thread Display Modes
Old 10-05-2002, 08:00 PM   #1
limjn
Registered User
 
Join Date: Oct 2002
Location: Malaysia
Posts: 3
Default Linking Javascript to Flash - Two Cases

Hi, I am new to this ActionScript, I have two cases below that hopefully someone can teach me how.

I have attached a HTML file which I have designed. Actually, I want to transfer everything I have designed to the Flash format. But I don't know much about linking Javascript to Flash, because inside my HTML there exists two Javascripts. I know there is this getURL, but I don't really know the actionscript that I should write.

So the first case is the text counting one. I want to restrict the total number of characters to be less than 160. Here is the Javascript for this:

<SCRIPT language = "JavaScript">
function checkCharsRemaining ( Target )
{
numChars = Target.value.length;

if ( numChars > 160 ) {
Target.value = Target.value.substring(0, 160);
CharsRemaining = 0;
window.alert("Your SMS should not exceed 160 characters!");
} else {
CharsRemaining = 160 - numChars;
}

document.MyForm.CharsRemaining.value = 160 - numChars;
}
</SCRIPT>

I named the message box as "Message", and in HTML, I have these two line of code as part of the Javascript:

onKeyUp="checkCharsRemaining(this)" onFocus="checkCharsRemaining(this)

The textbox with the number 160 is non-selectable, and I named it as "CharsRemaining".

How do I go about in Flash? I created one "Input Text", which is for the "Message" one; and the other is a "Dynamic Text", which is for the 160 characters. What code should I write to link them to the Javascript above?
------------------------------------------------------------------------------------

Now for the second case. This is a bit more complicated owing to the large amount of arrays that I have created. For this one, the scenario is whenever a user selects a country from the drop-down list, the second drop-down list, named "GSMCode", will automatically lists down the selected country's available GSM code. The Javascript for this is as follows:

<SCRIPT language = "JavaScript">
var Operators = document.MyForm.GSMCode;
var aOperators = new Array (
new Array ()........//many arrays here

if (Operators.options[0].text == "") {
UpdateKeywords(document.Target.Countries.selectedI ndex);
}

function UpdateKeywords(index){
var selectedArray = aOperators[index];
Operators.options.length = 0;
for (var i =0; i < selectedArray.length; i++){
if( Operators.options[i] == null){
Operators.options[i] = new Option(selectedArray[i]);
} else {
Operators.options[i].text = selectedArray[i];
}
}
Operators.selectedIndex = 0;
}
</SCRIPT>

Well, I guess this is a Flash MX question, but still I believe the concept might be the same. Now that I have created two combobox (the Flash UI component), named "Countries" and "GSMCode" respectively (same as that in HTML).

Is that anyway I can achieve the similar purpose in Flash, just like that in HTML? How do I link them to the Javascript?


Anyone's help or advice is very much appreciated and needed desperately.

Thank you in advance.
limjn is offline   Reply With Quote
Old 10-05-2002, 08:09 PM   #2
limjn
Registered User
 
Join Date: Oct 2002
Location: Malaysia
Posts: 3
Default The attachment...

Sorry, not sure just now if I have attached the file or not...
Attached Files
File Type: zip myform.zip (7.0 KB, 230 views)
limjn is offline   Reply With Quote
Old 10-07-2002, 03:25 PM   #3
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,048
Default

well, you should be able to do both of these things inside flash with no problem... i'm tight on time this am... i want to quickly browse thru the rest of the forum, then i'm off to a meeting.
if no one has helped you when i get back from that, i will try to take some time out to do so.
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 10-07-2002, 04:03 PM   #4
limjn
Registered User
 
Join Date: Oct 2002
Location: Malaysia
Posts: 3
Default Thanks! While waiting for help, I am still trying...

Hi, thanks for your time really. Actually I do try my best to learn from some sources (like Macromedia's help section), but their's is a straightforward getURL to one JavaScript function, while mine involves two targets.

Like these two lines:
onKeyUp="checkCharsRemaining(this)" onFocus="checkCharsRemaining(this)"
I am not sure where to put them...I put them after the getURL function, well nothing happens...
limjn is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:40 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.