1. jeroen_13's Avatar
    hi, i have a qnxstagewebview, and i'd like to add a custom css to it.

    i googled for a how-to but didnt found anything....


    my code:

    Code:
    package
    {
    	import flash.display.Sprite;
    	import flash.events.Event;
    	import flash.events.TimerEvent;
    	import flash.geom.Rectangle;
    	import flash.utils.Timer;
    	import qnx.events.WebViewEvent;
    	import qnx.media.QNXStageWebView;
    	import qnx.ui.events.*;
    	import qnx.ui.progress.PercentageBar;
    	[SWF(height="600", width="1024", frameRate="30", backgroundColor="#FFFFFF")]
    	
    	public class AIRHelloWorld extends Sprite
    	{
    
    		private var mySwv:QNXStageWebView;
    		private var myProgress:PercentageBar;
    		private var timer:Timer;
    		public function AIRHelloWorld()
    		{
    			initializeUI();
    		}
    		public function initializeUI():void
    		{
    			
    			timer = new Timer(500);
    			timer.addEventListener(TimerEvent.TIMER,handleTimerTick);
    			timer.start();
    			mySwv = new QNXStageWebView("myBrowser");
    			
    			mySwv.stage = this.stage;
    			mySwv.viewPort = new Rectangle(0,0,1024,600);
    			mySwv.addEventListener(WebViewEvent.DOCUMENT_LOAD_FINISHED, onLoad);
    			mySwv.addEventListener(WebViewEvent.DOCUMENT_LOAD_FAILED, onFail);
    			mySwv.loadURL("http://www.google.nl");
    			mySwv.scrollBy(100,100);
    			mySwv.zoomToFitWidthOnLoad = true;
    			mySwv.blockPopups = true;
    			mySwv.zOrder = -1;
    			myProgress = new PercentageBar();
    			myProgress.x = (400-myProgress.width) /2;
    			myProgress.y = (500-myProgress.height) /2;
    			myProgress.width = 200;
    			mySwv.userStyleSheet = ("data://styles.css");
    			mySwv.userAgent = ('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36');
    			this.addChild(myProgress);
    		}
    		private function handleTimerTick(e:Event):void
    		{
    			myProgress.progress = mySwv.loadProgress/100;
    		}
    		private function onLoad(e:WebViewEvent):void
    		{
    			myProgress.progress = 1;
    			mySwv.zOrder = 0;
    			myProgress.destroy();
    		}
    		private function onFail(e:WebViewEvent):void
    		{
    			trace("The document failed to load");
    		}
    	}
    }

    Thanks in advance, Jeroen



    People who also couldn't find the answer --> http://supportforums.blackberry.com/...ht/true#M28805
    09-06-13 12:52 PM
  2. Lendo's Avatar
    Any luck yet?
    09-06-13 08:27 PM
  3. jeroen_13's Avatar
    Nope, when I try the documentation code, I get a 1195 error. Weird

    Sent from my HTC Sensation using CB Forums mobile app
    09-07-13 02:10 AM
  4. pcshun's Avatar
    Hi Jeroen,

    I couldn't send you a PM due to the exceeded inbox quota so here I am

    I hear you. BB's documentation on Adobe Air SDK is poor to say the least.

    See the following example of how I have implemented custom css file in QNXStageWebView. In this example, the css file is located right under src->(default package).

    // locate the adBlock css
    adBlockCSSFile = File.applicationDirectory.resolvePath('custom.css' );
    adBlockCSSFile = new File(adBlockCSSFile.nativePath);
    targetWebViewInstance.userStyleSheet = adBlockCSSFile.url;

    Hope this helps!

    Thanks,
    Shun
    jeroen_13 likes this.
    09-09-13 06:59 AM
  5. jeroen_13's Avatar
    Deleted my PMS !

    Thank you so much for your help ! I'll try it tonight

    Jeroen

    Sent from my HTC Sensation using CB Forums mobile app
    09-09-13 07:32 AM
  6. jeroen_13's Avatar
    IT WORKED !


    i used this code:

    Code:
    var css = File.applicationDirectory.resolvePath('styles.css' );
    			css = new File(css.nativePath);
    			mySwv.userStyleSheet = css.url;
    in your code you didnt specified the 'var css'. but its working ! Thanks you so much !
    09-09-13 09:15 AM

Similar Threads

  1. BerryLeaks Presents: 2.1.0.1753 for BlackBerry PlayBook
    By masterscarhead1 in forum BlackBerry PlayBook OS
    Replies: 692
    Last Post: 02-17-14, 05:08 AM
  2. Playbook 0% battery! Red led DOES NOT turn on! Please help!?
    By Matt Peachey in forum BlackBerry PlayBook
    Replies: 12
    Last Post: 09-29-13, 10:49 AM
  3. Exchange my Playbook 64GB for 64GB USB 3.0 Flash Drive
    By Mikhou in forum The Marketplace - Buy, Sell & Trade
    Replies: 10
    Last Post: 09-17-13, 05:46 PM
  4. stand-buy made PlayBook unresponsive
    By DrBoomBotz in forum BlackBerry PlayBook
    Replies: 4
    Last Post: 09-06-13, 04:20 PM
  5. Video message from PlayBook?
    By lasm2000 in forum BlackBerry PlayBook
    Replies: 2
    Last Post: 09-05-13, 11:16 PM
LINK TO POST COPIED TO CLIPBOARD