A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: problem with ExternalInterface class

  1. #1
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508

    problem with ExternalInterface class

    ok, here's my AS3 code:

    Code:
    if (ExternalInterface.available)
    {
        // Perform ExternalInterface method calls here.
    
    	var banner_width:Number = ExternalInterface.call("getWidth");
    	//var banner_width:Number = 500;
    	ExternalInterface.call("trace", banner_width);
    }
    and here's my Javascript:

    Code:
    function getWidth() {
    	var banner_width = 600;
    	return banner_width;
    }
    
    function trace(val) {
    
    	alert(val + ' = width');
    }
    this works in FF and outputs 600 like expected and it doesn't work in IE, instead it outputs 0??? why is this handled differently in different browsers?
    thanks in advance!

  2. #2
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    Make sure you have allowScriptAccess = 'always' or 'samedomain' , and allowNetworking = 'all' or 'internal' ...and make sure you have those set in BOTH the object and embed tags. It may be that IE is reading the object tag only and people sometimes neglect to add those tags there. See if that helps...

  3. #3
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    I have "allowScriptAccess" set to "always" in both the OBJECT and EMBED tags...I don't see the "allowNetworking" property but I don't think this is the issue...everything works EXCEPT in IE the return of the function "getWidth()" never returns the correct value...it's like returning a value to AS3 doesn't work properly in IE but it does work fine in FF???

    I can pass params TO IE thru my AS3 code, so I know it's working in that respect, but when it comes to a return value for the function, it always bombs out! ideas? thx for the responses!

  4. #4
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    I haven't encountered this problem, but I've also never used ExternalInterface to directly return a value like that. Does it work if you do it through a callback function? Try this:

    Flash:
    Code:
    ExternalInterface.addCallback('gotWidth',this.gotWidth);
    function gotWidth(w:*):void {
      ExternalInterface.call('jsAlert',w);
    }
    ExternalInterface.call('jsGetWidth');
    Javascript:
    PHP Code:
    function jsGetWidth() {
       
    document.getElementById('myMovie').gotWidth(banner_width);
    }
    function 
    jsAlert(w) {
       
    alert(w);


  5. #5
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    the examples seem to provide for a return result like that....the way you mentioned should work, but of course doesn't, even with tailoring...it's like it doesn't recognize my named Flash object within the HTML page. I have id and name set to "banner" and the documentation says to do it this way from Javascript:

    Code:
    ...
    var result = banner.gotWidth(someWidth);
    ...
    of course it doesn't work....also, does the DOM get processed differently in different browsers?

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    The answer to your problem may be here:
    http://livedocs.adobe.com/flash/9.0/...Interface.html
    You may have to use a delay.
    I don't have any Flash here currently, so I cannot check it myself.
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center