Solved

flash code causes url to open twice

Posted on 2008-10-22
2
364 Views
Last Modified: 2012-05-05
The following flash code is a glow ball that is to go to a url when clicked.

This code when added (below) functions correctly but does launches the URL 2x. Please help.
btn_mc.onPress = function ()
{
   getURL("http://www.tomahawktko.com", "_self");
}

//import the flash filter classes that also included the GLOW filter
import flash.filters.*;
//import the tween classes to give a little bouncy effect to object 
import mx.transitions.Tween;
import mx.transitions.easing.*;
 //ok instead of putting those parameters directly into the GlowFilter Object
// I've assigned those parameters to variables for ease of change and understand
var glowColor:Number = 0xFFFF00;//color that will glow around the object
var glowAlpha:Number = 25;// transparancy of the color
var blurX:Number = 10; //initial value of color floodingin horizontal direction
var blurY:Number = 10; //initial value of color floodingin vertical direction
var glowStrength:Number = 3; // the more the value the more the strength of the glowcolor
var glowQuality:Number = 3; // qulaity of the glow, it is set to max now
var glowInner:Boolean = false; // unable inner glow 
var glowOuter:Boolean = false; // unable outer glow 
//all the Glow properties mentioned in the GlowFilter are assing to the variables
var glowMe:GlowFilter = new GlowFilter(glowColor, glowAlpha, blurX, blurY, glowStrength, glowQuality, glowInner, glowOuter);
// GlowFilter properties has given to the Object
btn_mc.filters = [glowMe];
//function for the RollOver event with dynamic Glow setting.Glow setting changes on RollOver
btn_mc.onRollOver = function() {
	growBall();
	this.onEnterFrame = function() {
		if (glowMe.blurX<40) {
			glowMe.blurX += 2;
			glowMe.blurY = glowMe.blurX;
		}		
		else {
			delete this.onEnterFrame;
		}
		this.filters = [glowMe];
	};
};
//function for the RollOut event that takes back the object glow to its initial stage
btn_mc.onRollOut = function() {
	shrinkBall();
	this.onEnterFrame = function() {
		this.filters = [glowMe];
		if (glowMe.blurX>10) {
			glowMe.blurX -= 2;
			glowMe.blurY = glowMe.blurX;
		} else {
			delete this.onEnterFrame;
		}
	};
};
btn_mc.onPress = function ()
{
   getURL("http://www.tomahawktko.com", "_self");
}
 
// button GROW and SHRINK code starts here
var xGrow:Tween;
var yGrow:Tween;
var xShrink:Tween;
var yShrink:Tween;
 
btn_mc._xscale = btn_mc._yscale = 50;
 
function growBall(){
    xShrink.stop();
    yShrink.stop();
    xGrow = new Tween(btn_mc, "_xscale", Elastic.easeOut, 50, 58, 2, true);
    yGrow = new Tween(btn_mc, "_yscale", Elastic.easeOut, 50, 58, 2, true);
	
}
function shrinkBall(){
    xGrow.stop();
    yGrow.stop();
    xShrink = new Tween(btn_mc, "_xscale", Elastic.easeOut, 58, 50, 3, true);
    yShrink = new Tween(btn_mc, "_yscale",Elastic.easeOut, 58, 50, 3, true);
}
 
 
 
/*
function doTween() {
	var mcXScale:Tween = new Tween(btn_mc, "_xscale", Elastic.easeOut, 100, 40, 3, true);
	var mcYScale:Tween = new Tween(btn_mc, "_yscale", Elastic.easeOut, 100, 40, 3, true);
} */

Open in new window

0
Comment
Question by:Wanderinglazyeye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Expert Comment

by:SplitPerception
ID: 22782910
In your html file that you imported your swf in... let's say index.html you need to edit the code to set a parameter "allow script access" and set to always.

the script below is what automatically loads in dreamweaver when you import your swf, if you look towards the bottom you will see (<param name="allowScriptAccess" value="always" />) add this in manually into the html file and you actionscript code should work fine

<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','800','height','200','src','/flash/now_header','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','wmode','transparent','allowscriptaccess','always','movie','/flash/now_header' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="800" height="200">
    <param name="movie" value="/flash/yourfile.swf" />
    <param name="quality" value="high" />
    <param name="wmode" value="transparent" />
    <param name="allowScriptAccess" value="always" />
    <embed src="/flash/now_header.swf" width="800" height="200" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always"></embed>
  </object>
</noscript>
0
 
LVL 9

Accepted Solution

by:
asaivan earned 500 total points
ID: 22783029
Well, one thing I would do is set my onPress handler to onRelease.  onPress is rarely used, as it can cause weird usability issues.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Running Mp4 or Flash Video 1 149
Can't play streaming video on event.on24.com 7 494
Specific format 21 240
How to max the resolution on a Canon Powershot ELPH 520 HS? 7 22
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
It’s easy to embed any of your public Prezi presentations on your website or social network to share with others. Learn how simple it is in this tutorial.

752 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