Array inside getURL not working
I'm trying to put links on multiple images using the titles of the images that I keep inside an array
var imagesTitles = new Array("Image title1", "Image title2", .... );
I'm starting a for loop here and after I replace the empty spaces with hyphens and lowercase the image titles I'm trying to attach a link to every instance like this:
getURL(imageLinks[i], "_blank");
If I trace imageLinks it looks like this http://www.mysite.com/image-title
The browser opens and I get http://www.mysite.com/undefined
What would be the correct way to use getURL with an array?
Here is my code:
String.prototype.replace = function(s, r) {
return this.split(s).join(r);
for (var i:Number = 0; i < imagesTitles.length; i++) {
imageLink[i] = imageTitles[i];
imageLink[i] = imageLink[i].replace(" ", "-");
imageLink[i] = imageLink[i].toLowerCase();
imageLink[i] = "http://www.mysite.com/" +imageLink[i] + "/";
trace (imageLink[i]); // trace here shows a list of valid urls
gallery_mc["image" + i.toString()].onRelease = function(){
trace (imageLink[i]); // trace here shows undefined
getURL(imageLink[i], "_blank");
Must be a scope problem but I just started using AS2, I don't know how to fix it.
Similar Messages
-
Geturl not working of ferris wheel effect
Hi,
Thanks to Rob i have managed to get the effect i want and he
has kindly given me the code to add a geturl to each of the images
on the ferris wheel effect. The only thing is that when i view it
it does not work so maybe i am missing somthing, see what you guys
think:
// create an onRelease function for each of the movieClips in
the
//objectsInScene array...
for (i in objectsInScene) {
objectsInScene.onRelease = function() {
useLink(this);
// this function will figure out which pane was clicked on
and execute a
//getURL for a specific URL...
//substitute your own urls...
function useLink(thisOne) {
switch (thisOne) {
case theScene.pane :
getURL("firstURL.html", "_blank");
break;
case theScene.pane1 :
getURL("secondURL.html", "_blank");
break;
case theScene.pane2 :
getURL("thirdURL.html", "_blank");
break;
case theScene.pane3 :
getURL("fourthURL.html", "_blank");
break;
case theScene.pane4 :
getURL("fifthURL.html", "_blank");
break;
case theScene.pane5 :
getURL("sixthURL.html", "_blank");
break;
case theScene.pane6 :
getURL("seventhURL.html", "_blank");
break;
case theScene.pane7 :
getURL("eighthURL.html", "_blank");
break;
case theScene.pane8 :
getURL("ninthURL.html", "_blank");
break;
case theScene.pan9 :
getURL("tenthURL.html", "_blank");
break;
case theScene.pane10 :
getURL("eleventhURL.html", "_blank");
break;
case theScene.pane11 :
getURL("twelvthURL.html", "_blank");
break;
case theScene.pane12 :
getURL("thirteenthURL.html", "_blank");
break;
break;
case theScene.pane13 :
getURL("fourteenthURL.html", "_blank");
break;
case theScene.pane14 :
getURL("fifteenthURL.html", "_blank");
break;
default :
trace ("uh oh");
Any suggestions please post.
Thanks,
NeilThis is all of my code:
// create a scene movieclip to contain all 3D elements
// and center it on the screen.
this.createEmptyMovieClip("theScene", 1);
theScene._x = 290;
theScene._y = 220;
// now we'r going to create an array to keep track of all the
// objects in the scene. That way, to position all the
objects
// you just need to loop through this array.
objectsInScene = new Array();
var paneArray:Array = ["pane", "pane1", "pane2", "pane3",
"pane4", "pane5", "pane6", "pane7", "pane8", "pane9", "pane10",
"pane11", "pane12", "pane13", "pane14"];
var paneArray:Array ;
paneArray[0] = "pane";
paneArray[1] = "pane1";
paneArray[2] = "pane2";
paneArray[3] = "pane3";
paneArray[4] = "pane4";
paneArray[5] = "pane5";
paneArray[6] = "pane6";
paneArray[7] = "pane7";
paneArray[8] = "pane8";
paneArray[9] = "pane9";
paneArray[10] = "pane10";
paneArray[11] = "pane11";
paneArray[12] = "pane12";
paneArray[13] = "pane13";
paneArray[14] = "pane14";
// no camera, but a rotation will be needed to keep track of
the
// spinning involved (though its the same as the camera)
spin = 0;
// focal length to determine perspective scaling
focalLength = 250;
// the function for controling the position of a friend
displayPane = function(){
var angle = this.angle - spin;
var x = Math.cos(angle)*this.radius;
var z = Math.sin(angle)*this.radius;
var y = this.y;
var scaleRatio = focalLength/(focalLength + z);
this._x = x * scaleRatio;
this._y = y * scaleRatio;
this._xscale = this._yscale = 40 * scaleRatio;
// on top of the normal scaling, also squish the
// _xscale based on where in the rotation the pane is
// since you would be looking at its side when at a z
// of 0, it would be at its thinnest which would be
// 0 since its a completely flat pane. So for that,
// we can use the trig function of z (sin) to squish the
// _xscale based on its position in z.
this.swapDepths(Math.round(-z));
// attach each pane in a loop and arrange them in a
// circle based on the circumference of the circle
// divided into steps
angleStep = 2*Math.PI/15;
for (i=0; i<15; i++){
attachedObj = theScene.attachMovie(paneArray
, "pane"+i, i);
attachedObj.angle = angleStep * i;
attachedObj.radius = 160;
attachedObj.x = Math.cos(attachedObj.angle) *
attachedObj.radius;
attachedObj.z = Math.sin(attachedObj.angle) *
attachedObj.radius;
attachedObj.y = 30;
attachedObj.display = displayPane;
objectsInScene.push(attachedObj);
panCamera = function(){
// rotate camera based on the position of the mouse
spin += this._xmouse/4000;
// Now, with the camera spun, you need to perform the
rotation
// of the camera's position to everything else in the scene
for (var i=0; i<objectsInScene.length; i++){
objectsInScene.display();
// make each figure run backAndForth every frame
theScene.onEnterFrame = panCamera;
// create an onRelease function for each of the movieClips in
the
//objectsInScene array...
for (i in objectsInScene) {
objectsInScene.onRelease = function() {
useLink(this);
// this function will figure out which pane was clicked on
and execute a
//getURL for a specific URL...
//substitute your own urls...
function useLink(thisOne) {
switch (thisOne) {
case theScene.pane :
getURL("
http://www.totalamber.com/default.htm",
"_blank");
break;
case theScene.pane1 :
getURL("secondURL.html", "_blank");
break;
case theScene.pane2 :
getURL("thirdURL.html", "_blank");
break;
case theScene.pane3 :
getURL("fourthURL.html", "_blank");
break;
case theScene.pane4 :
getURL("fifthURL.html", "_blank");
break;
case theScene.pane5 :
getURL("sixthURL.html", "_blank");
break;
case theScene.pane6 :
getURL("seventhURL.html", "_blank");
break;
case theScene.pane7 :
getURL("eighthURL.html", "_blank");
break;
case theScene.pane8 :
getURL("ninthURL.html", "_blank");
break;
case theScene.pan9 :
getURL("tenthURL.html", "_blank");
break;
case theScene.pane10 :
getURL("eleventhURL.html", "_blank");
break;
case theScene.pane11 :
getURL("twelvthURL.html", "_blank");
break;
case theScene.pane12 :
getURL("thirteenthURL.html", "_blank");
break;
break;
case theScene.pane13 :
getURL("fourteenthURL.html", "_blank");
break;
case theScene.pane14 :
getURL("fifteenthURL.html", "_blank");
break;
default :
trace ("uh oh");
} -
Javascript calls via getURL not working anymore
After upgrading to flash player 9,0,115,0 a simple call like
getURL("javascript(alert'message')); doesn't work anymore on
Internet Explorer (it fails without any error in policyfiles.txt,
but it still work on Firefox). My IE version is 7.
I can't use ExternalInterface 'cause i need to publish as
Flash Player 7 AS2.0.
Any comment or suggestion?I have a similar problem. When running a local HTML file,
using IE7 and FP 9,0,115,0, all the getURL function calls cease to
work.
If I downgrade to FP8, still using IE7, everything works.
If I downgrade to IE6, still using FP9.0.115.0, everything
works.
If I load the HTML via HTTP (instead of local), using IE7 and
FP9.0.115.0, everything works.
If I use Firefox, with FP9.0.115.0, everything works.
So, the function calls fail only when the swf is contained on
a
local HTML file, using
IE7, and
FP9.0.115.0. The problem is, most of our customers have that
software profile, and all of them need to load the content locally
(its very heavy for network transmission).
All the getURLs are like this:
getURL("javascript:someFunction()");
We're setting the 'allowScriptAccess' to 'always'.
Also, if we put the OBJECT tag inside the HTML (instead on an
external JS file), the function calls still do not work. -
Hi,
I'm new to the whole flex/as/flash builder, but I'm trying to do a seemingly simple thing and it's not working.
Flex Mobile project has a button and data grid. When I press the button a 2 dimensional array is build with random numbers. Then I want to show the array on datagrid.
The array does get build but it's not showing up on data grid.
Any help would be appreciated as I've spent lots of time on this without any solution.
Thanks,
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import flash.events.Event;
import mx.collections.ArrayList;
import mx.collections.ArrayCollection;
import spark.events.ViewNavigatorEvent;
protected function cmdStart1_clickHandler(event:MouseEvent):void
DataGridTest1();
protected function DataGridTest1():void
var board:Array = [];
var arrList:ArrayList = new ArrayList();
var i:int = 1;
var j:int;
text.text = "";
for(i; i<=5; i++)
board[i] = [];
j = 1;
for(j; j<=6; j++)
board[i][j] = Math.round(Math.random() * 10);
arrList.source = board;
grid.dataProvider = arrList;
]]>
</fx:Script>
<s:Button id="cmdStart1" x="53" y="100" width="394" height="62" label="DataGridTest1 (ArrayList to Grid)"
click="cmdStart1_clickHandler(event)"/>
<s:TextArea id="text" x="53" y="240" width="394" height="162"/>
</s:View>Sorry, the <s:TextArea shouldn't be there, I was using it to debug the array. I removed the <s:DataGrid> instead of <s:TextArea> by mistake.
Also, I tried to move arrList out of the function but that didn't work.
Here's the entire code again:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import flash.events.Event;
import mx.collections.ArrayList;
import mx.collections.ArrayCollection;
import spark.events.ViewNavigatorEvent;
protected function cmdStart1_clickHandler(event:MouseEvent):void
DataGridTest1();
protected function DataGridTest1():void
var board:Array = [];
var arrList:ArrayList = new ArrayList();
var i:int = 1;
var j:int;
text.text = "";
for(i; i<=5; i++)
board[i] = [];
j = 1;
for(j; j<=6; j++)
board[i][j] = Math.round(Math.random() * 10);
arrList.source = board;
grid.dataProvider = arrList;
]]>
</fx:Script>
<s:Button id="cmdStart1" x="53" y="100" width="394" height="62" label="DataGridTest1 (ArrayList to Grid)"
click="cmdStart1_clickHandler(event)"/>
<s:DataGrid id="grid" x="500" y="100" width="236" height="226" />
</s:View> -
GetURL not working in IE 8 or Firefox 3
I am trying to create a button which links to another website upon clicked. My code is as follows:
on(release) {
getURL("http://www.adobe.com", "_blank");
However, this does not work as the button act as if no event has been triggered. I am using Flash CS4 and my movie was exported for actionscript 2. I have attached the fla for your reference. Thanks in advance.I'm going through Classroom in a Book for ActionScript 3.0 and I'm having the same problems. I beat my brains out trying to figure out why my simple link to the Flash site wouldn't work, only to find out the completed files didn't work either. They do seem to work in Safari so I'm guessing it's some kind of security setting ? It lauches the browser but just sits there without opening any URL.
Anyone got an answer for this ? -
I have this simple code on a button and all seemed to be
working well until I cut the movie to CD. From the CD I click on
the button and nothing happens. I am not sure what additional
information to provide so please ask me for the whatever you may
need to assist. Thanks in advance.
on (release){
getURL("docs/tm9-2815-257-24.swf","_blank")
}Hi
Having the same problem here...
You can't use absolute path because you dont know drive letters, you can't infere CD is grabbing D: letter, or E:
Relative path is not working for me too, dunno why :/
i'm working in a CD too, but my animation is having clicks only, so i tried
on(release) {
getURL("./33903.htm", "_self");
my flash file is in that folder, one level up, not working thought XD -
HELLLLLLLP! GetURL not working!!!
Hello All,
I'm working in CS3. and have created buttons using the
following code:
myButton_btn.onRelease=function(){
getURL("
http://www.arcticfalls.com/home-Water.html/",
"_self");
The page is not found when clicked. Here's what it is going
on in the address bar.
http://02aa6aa.netsolstores.com/page-not-found.aspx?404;http://www.arcticfalls.com:80/home -Water.html/
Page Not Found
The page you have requested cannot be found or has been
removed. Please use the menus provided to navigate this store.
Seems it is adding a :80 after the .com.
Any ideas... or am I using the wrong code.
This worked prior to adding the full link to page:
myButton_btn.onRelease=function(){
getURL("
http://www.arcticfalls.com/",
"_self");
Direct links to website work... why is the direct link not
working?
It used to work the same way a couple versions back.
Any help is appreiciated.
Thanks,
dbrox08It should be like this:
myButton_btn.onRelease=function(){
getURL("
http://www.arcticfalls.com/home-Water.html",
"_self");
The "/" shouldnt be in the end of the URL.
/ Pinnennet -
Button with GetURL not working
HI,
I have made a button symbol (trying to make a skip intro
button) which is just unselectable text. I have made all 4 states
including the hit state.
I have used the either
on (release) {
getURL("who.html", "_self");
or
getURL("who.html", "_self");
Nothing works when i click the link,. I know the button works
because my over state happens.
I'm sure I'm missing something simple. I have done this all
the time and I actually have a getURL that works but its not on a
button, its just at the end of the flash.this is a scope issue, unless the swf file is mounted online,
it wont' be able to open a relative path. If you want to test the
swf from your local machine, mount the 'who.html' online and then
use a fully-qualified path as in:
getURL( '
http://www.thedomain.com/who.html'
, '_self');
(if in the root directory folder) -
GetURL not working without WWW
Hi there,
I have created one website www.slcc.sg.
Problem is I type www.slcc.sg , links its work
but I type
http://slcc.sg, all link are not
working,
please tell me whats problem this
Thanks,
Regards,
Darpani don't see a problem.
-
GetURL not working on all computers?
I have a banner with a link to a site, but it won't activate
on most browsers. On my computer it works on Firefox or Safari, but
for most other people, clicking has no effect. Maybe it's a Flash
setting, or a Flash player setting? How can I change this so that
when people click they get redirected?
Thank youHi Jean,
Actually, we have an issue with scalable HTML content and smartshapes where smartshapes do not work as buttons in scaled mode.
Please try switching off the "Scalable HTML Content" option in the Publish dialog before publishing. Then it should work.
Regards,
Chinmay -
GetURL not working when swf is loaded into another swf
Ok, I need some help for something relatively simple which
for some reason I've not been able to find any information on at
all?
Hopefully it will be something easy to fix.
Essentially I have the following:
my main movie "Home.swf"
another movie "Sub.swf"
I've loaded "Sub.swf" into "Home.swf" via an empty movieclip.
Within "Sub.swf" I have some links which when clicked call
getURL and open a HTML page in the browser.
But for some reason the getURL isn't working and I believe
its because the getURL is called from a loaded movie within
"Home.swf".
I've tried changing the actionscript to:
_root.getURL('/mypage.html');
_parent.getURL('/mypage.html');
but neither (_root / _parent) seems to work?
Need help here please.
Many thanks.
Kind regards,
M.Hi kglad,
Yes the button is definitely firing ok.
In the "Sub.swf" movie, on the second frame of the timeline
(the first frame is some preloader code) there is the following
code:
imgMC.mascara.onPress = function() {
//trace('mc[activo] = ' + mc[activo]);
switch(mc[activo])
case _level0.imgMC.MC0:
trace('0 - ' + mc[activo])
break;
case _level0.imgMC.MC1:
trace('1 - ' + mc[activo])
break;
case _level0.imgMC.MC2:
trace('2 - ' + mc[activo])
break;
case _level0.imgMC.MC3:
trace('3 - ' + mc[activo])
break;
case _level0.imgMC.MC4:
trace('4 - ' + mc[activo])
break;
case _level0.imgMC.MC5:
trace('5 - ' + mc[activo])
break;
If I run this movie in Flash (ctrl-enter) then the trace
works fine.
But the trace stops working when I run the main "Home.swf"
movie in Flash (ctrl-enter) when the "Sub.swf" is loaded into an
empty movie clip.
And when I change the trace for a getURL and test in a
browser it still doesn't work?
What do you reckon?
Thanks.
M. -
Drag/Drop inside SWFLoader not working
I've got a Flex application that loads a secondary Flex app via SWFLoader. The secondary app uses drag/drop operations to rearrange components, delete them etc. The secondary app works perfectly while it is running by itself (eg. not 'embedded' via SWFLoader into the main app).
Once I load it into the main application using a SWFLoader drag/drop operations no longer work correctly. All other events seems to work fine. It is only drag/drop that don't always work right.
Is there something I am missing that would cause this issue? I'm thinking there may be a property I need to set on the SWFLoader. Hopefully someone can help.Thanks Alex.
I did as you say, and DragManager is in the report file in several places. Also, Drag/Drop does work inside of SWFLoader for the TileList in the loaded app, and even somtimes as it should as far as the drag/drop operation I am talking about, but not always.
It seems to work sometimes and not others. When it does work it is not nearly as smooth as when I run the app as a "stand alone" and I never see the drag proxy while dragging inside of SWFLoader.
Is there anything else that could be causing these issues? -
I have a file in the root of a web server and prior to Flash
Player 9 (I believe this to be the culprit) I was able to simply
attach the following code to a button and the file would download
(it will work in Mozilla browsers, just not IE):
on(release){
getURL("file.zip", _blank);
Any ideas?I removed _blank and it works now.
-
Fscommand inside onSoundComplete not working
Hi there,
I'm building a flash movie that needs to run a javascript function afer a particular sound finishes playing.
Here's the code i'm curently using:
var som:Sound = new Sound();
som.attachSound("1_07_8.mp3");
som.start(0,0);
som.onSoundComplete = function(){
fscommand("animation", "ready");
I'm publishing the HTML as a template for Flash with FSCommand, and I have the following code on the HTML inside the DoFSCommand javascript function:
if (command == "animation") {
alert("This slide is " + args);
This is placed inside an IIS aplication, so that no security issues prevent the comm between the SWF and the HTML/Javascript
I've successfully done this on a test SWF, but there, the fscommand was triggered by an onPress event from a button. Is it not possible to trigger it with the onSoundComplete event?
ThxHave you though about using the ExternalInterface class instead of FSCommand?
It is the more modern approach to communicating between Flash and the web page. You should be able to find some helpful info if you search Google. Here's a link to an article that covers numerous forms of communications including the ExternalInterface approach.
http://www.adobe.com/devnet/flash/articles/external_interface.html
If going that route doesn't appeal to you, turn your attention away from the problem you thought you had and try to recreate what you say you had working from the html end. -
For dynamically allocated double arrays, sizeof() does not work
For a typical double array, if you need to get the size, you would use
numElems=(sizeof(myArray)/sizeof(myArray[0]));
However, for dynamically allocated double arrays (see here for example) this no longer works.
For the example above, sizeof(myArray) returns 4, and sizeof(myArray[0]) returns 8.
Solved!
Go to Solution.That's because sizeof(myArray) is the size of the pointer to the dynamically allocated array.
sizeof(myArray[0]) is the size of a double (8 bytes).
If you know the size you malloc'd then just use this instead of the sizeof(myArray) function.
Array size (for use in bounds checking for example) is a compile-time thing in C89 (though CVI will hack in run-time bounds checking for you in a debug compile). So even if you cast a malloc'd buffer pointer to an array type, the compiler's out of the picture at run time when the buffer gets established to a (potentially) run-time determined size, so it can't help you. More modern languages (e.g. Java, C#) all get around this problem. C99 allows variable length arrays to be declared but I'm not sure NI implemented this in their C99 upgrades.
Maybe you are looking for
-
CD/DVD drive no longer accepts media after Tiger
I have a PowerBook G4 17" (about 6 mos old) that no longer takes a CD or DVD after upgrading to TIger (10.4.2). The drive does not even appear on the System Profiler. The last CD that it took was the Tiger installer CD. Any advice would be greatly ap
-
In jsp:includes , is there a flush="false" in jsp 1.1
In <jsp:includes>, is there a flush="false" in jsp 1.1...i know that it's going to be in jsp 1.2 but is there something like it that i can use in jsp 1.1.
-
HI All, Scenario: Sync Proxy to SOAP Scenario. just wanted to know below 1) is it possible to Test the sync Scenario using SOAP UI or any other tools when SOAP is target? 2)Is it possible to Trigger a Proxy Message from ABAP system and Get the respo
-
Please help!!! can't install itunes on windows 8
my brother got a new laptop (sony vaio) with windows 8. as he tries to install itunes, an error indication keeps appearing, telling him that the itunes setup is not compatible. what should he do to solve the problem? he tried installing the whole thi
-
Logic pro 9.1.7 plus EW Symphonic choirs?
I am using EW SC in Logic and there is a point in the choir set up where the text has been entered and the EW software asks to play the melody for that text. I have the melody on a single region track but as long as the Choir's window for"Play the m