最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I run a jQuery function using AS3 - Stack Overflow

programmeradmin0浏览0评论

I am trying to run a jQuery function on my HTML page from AS3.

This is my jQuery function:

function loadImage(imageNumber)
  {
    imageURL = '<img src="images/image' + imageNumber + '.jpg">';
    $("#imageBox").html(imageURL);
  }

Here are the settings of my flash file in the HTML page:

<param name="allowScriptAccess" value="always" />
<param name="bgcolor" value="#ffffff" />    
<embed src="links.swf" quality="high" bgcolor="#ffffff" width="320" height="242" name="links" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="" />

and finally... here is the AS3 script in my .swf file:

function gotoImage1(e:MouseEvent):void {
    var jsmand:String = "loadImage(1);"
    var link:URLRequest = new URLRequest("javascript:" + jsmand + "");
    navigateToURL(link, '_self');
}

Thankyou in advance for taking the time to look and any help is massively appreciated.

Kindest Regards.Tom

I am trying to run a jQuery function on my HTML page from AS3.

This is my jQuery function:

function loadImage(imageNumber)
  {
    imageURL = '<img src="images/image' + imageNumber + '.jpg">';
    $("#imageBox").html(imageURL);
  }

Here are the settings of my flash file in the HTML page:

<param name="allowScriptAccess" value="always" />
<param name="bgcolor" value="#ffffff" />    
<embed src="links.swf" quality="high" bgcolor="#ffffff" width="320" height="242" name="links" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe./go/getflashplayer" />

and finally... here is the AS3 script in my .swf file:

function gotoImage1(e:MouseEvent):void {
    var jsmand:String = "loadImage(1);"
    var link:URLRequest = new URLRequest("javascript:" + jsmand + "");
    navigateToURL(link, '_self');
}

Thankyou in advance for taking the time to look and any help is massively appreciated.

Kindest Regards.Tom

Share Improve this question asked Apr 10, 2009 at 21:00 TischTisch 2,6474 gold badges28 silver badges34 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

You can use ExternalInterface instead:

if (ExternalInterface.available) {
    ExternalInterface.call('function(){ alert("test"); }');
}

Documentation: http://livedocs.adobe./flex/3/langref/flash/external/ExternalInterface.html

The final solution was:

function gotoImage2(e:MouseEvent):void 
{
    if(ExternalInterface.available)
    {
        ExternalInterface.call('function(){ loadImage(2); }');
    }
}

Just in case anyone wanted to see how it ended...

发布评论

评论列表(0)

  1. 暂无评论