Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-19-2011, 08:29 PM   #1
canarchy
Registered User
 
Join Date: Jul 2011
Posts: 4
Default ExternalInterface breaks swf

I have a weird problem here in which my mxml compiles fine but when I load it in the webpage all it shows is a black box....

I have isolated the cause to be line 46 which is
ActionScript Code:
ExternalInterface.addCallback("toggle",playerToggle);

Can't seem to find anybody on Google who has the same issue....

Here is my entire script:

ActionScript Code:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="[...]"     layout="absolute" usePreloader="false"     applicationComplete="init()"     backgroundColor="#000000"     backgroundAlpha="1">         <!-- Load styles -->         <mx:Script>             // Imports         import flash.external.ExternalInterface;         import mx.core.FlexGlobals;          // Important variables             private var nc:NetConnection; // net connection             private var stream:NetStream; // net stream             private var video:Video;      // video             private var meta:Object;      // meta data                         // This succker is loaded. Act like it.         private function init():void         {             // No scaling             stage.scaleMode = StageScaleMode.NO_SCALE;                         // Flash Vars             var params:Object = FlexGlobals.topLevelApplication.parameters;                         /* Not right now             if( params.stylesheet )             {                 FlexGlobals.topLevelApplication.styleManager                     .loadStyleDeclarations( params.stylesheet );             }*/                         // Position             playBox.width  = overlay.width  = stage.stageWidth;             playBox.height = overlay.height = stage.stageHeight;                                                         // External Callbacks             ExternalInterface.addCallback("toggle",playerToggle);                         // add event to overlay             overlay.addEventListener(MouseEvent.CLICK, overlayClick);                         // Start handling video stuff             var nsClient:Object = {};             nsClient.onMetaData = ns_onMetaData;             nsClient.onCuePoint = ns_onCuePoint;             nc = new NetConnection();             nc.connect(null);             stream = new NetStream(nc);             stream.play("video.flv");             stream.pause();             stream.seek(0);             stream.client = nsClient;                         // create the video object             video = new Video();             video.attachNetStream(stream);                         playBox.addChild(video);                         video.width = stage.stageWidth;             video.height = stage.stageHeight;                                 }                 // Meta and cue         private function ns_onMetaData(item:Object):void {             trace("meta");             meta = item;             // Resize Video object to same size as meta data.                         var w:Number, h:Number;             if( item.width > stage.stageWidth )                 {   w = stage.stageWidth; }             else                 {   w = item.width; }             if( item.height > stage.stageHeight )                 {   h = stage.stageHeight; }             else                 {   h = item.height; }                         video.width = w;             video.height = h;                         var diffW:Number = stage.stageWidth-w;             var diffH:Number = stage.stageHeight-h;                         video.x = diffW/2;             video.y = diffH/2;         }         private function ns_onCuePoint(item:Object):void {             trace("cue");         }                 // some other stuff                 // overlay clicked         private function overlayClick(event:Event):void         {             playerToggle();         }                         // in player commands, only accessible in house         public function playerToggle():void         {             stream.togglePause();         }                             </mx:Script>         <mx:UIComponent id="playBox" x="0" y="0">     </mx:UIComponent>     <mx:Canvas id="overlay" backgroundColor="#FFFFFF" backgroundAlpha="0" x="0" y="0"/>     </mx:Application>

Thanks for any help you can give me.

Edit:
Without that line everything works great just without the access via javascript.

Last edited by canarchy; 07-19-2011 at 08:43 PM.
canarchy is offline  
Old 07-19-2011, 10:01 PM   #2
canarchy
Registered User
 
Join Date: Jul 2011
Posts: 4
Default

Never mind. Accidentally opened the file through the explorer instead of the localhost.... It works.
canarchy is offline  
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:53 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.