-
_root in as3
Hi,
I'm new to as3. I am trying to convert a script from as2 to as3.
the code that I am struggling with is as follows:
getURL('javascript:SetSliderValue(' + _root.cnt_txt.text + ')');
I've converted it to:
var request: URLRequest = new URLRequest('javascript:SetSliderValue('+ _root.cnt_txt.text +')');
navigateToURL(request, "_blank");
But it doesn't link as I would hope.
I can't work out how the _root function should be revised
Any suggestions/ corrections
thanks
-
OOP is one letter from OOPS
Try root (without _), but use with caution.
-
Senior Member
Where is that line of code written, on the main timeline or in a movieclip?
- The right of the People to create Flash movies shall not be infringed. -
-
Hi,
I've now made the scrip produce the correct code by removing the _root part altogether (thanks for your help), but it still doesn't work.
The as2 version seems to put the url and 'press enter' for want of a better description, whereas the as3 version seems to put the utl into the browser, but doesn't make it press the enter key.
I'm not surre if either script actually presses the enter key, but hopefully you can understand what I mean.
The as3 script is in a movie clip, in layer1: frame1.
The as2 script seems to be attached to a symbol definition, but I'm not if this is different to being part of the layer1:frame1 part of the script
I hope this makes sense and thanks for helping so far
-
Although some browsers will accept javascript interaction from flash like that, you are better off using ExternalInterface, as that's what it was designed for.
Your code would look something like this:
Code:
import flash.external.ExternalInterface;
if (ExternalInterface.available){
ExternalInterface.call('SetSliderValue', cnt_txt.text);
}//else trace an error or something so you know what went wrong.
Note that you must test this on a server, and you must add "allowScriptAccess='always'" to your embedding tag.
-
thank you 5TonsOfFlax!
You have cracked it!
Have a beer on me
Many many thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|