Note that there are some explanatory texts on larger screens.

plurals
  1. POMaking buttons link - Adobe flex - Blackberry Playbook
    primarykey
    data
    text
    <p>Maybe a simple question but I'm having alot of trouble making a button change the view of a Flex blackberry playbook app. I am coding it <strong>entirely in actionscript</strong>, no MXML.</p> <pre><code>myButton.addEventListener(MouseEvent.CLICK, doSomethingOnClick); private function doSomethingOnClick(e:MouseEvent):void { navigator.pushView(view.Login, "testdata"); } </code></pre> <p>When I try this I get:</p> <p>1120: Access of undefined property navigator.</p> <p>Which is weird as it works in a MXML file. How do I change views in actionscript?</p> <p>Thanks Phil</p> <p><strong>EDIT:</strong> Cheer J_A_X, but now i have:</p> <pre><code>navigator = new ViewNavigator(); navigator.pushView(net.airpoint.assessments.view.Login, " "); </code></pre> <p>TypeError: Error #1009: Cannot access a property or method of a null object reference.</p> <p>Apologies, as I realise this is really simple stuff but it just isnt clicking!</p> <p><strong>Update 2</strong> *<em>Assessments.as</em>*</p> <pre><code>package { import flash.display.Sprite; import flash.events.Event; import net.airpoint.assessments.view.*; import qnx.ui.core.Container; import qnx.ui.core.ContainerAlign; import qnx.ui.core.ContainerFlow; import qnx.ui.core.Containment; import qnx.ui.text.Label; import spark.components.ViewNavigator; [SWF(height="600", width="1024", frameRate="30", backgroundColor="#FFFFFF")] /* Main Layout */ public class Assessments extends Sprite { //containers private var main:Container; private var menu:Container private var firstLabel:Label; private var navigator:ViewNavigator; public function Assessments() { initializeUI(); } private function initializeUI():void { main = new Container(); main.padding = Vector.&lt;Number&gt;([20,20,20,20]); main.flow = ContainerFlow.HORIZONTAL; main.debugColor = 0xFFCC00; firstLabel = new Label(); firstLabel.text = "First label"; firstLabel.size=35; main.addChild(firstLabel); addChild(main); navigator = new ViewNavigator(); navigator.pushView(Login, " "); } } } </code></pre> <p><strong>Login.as</strong></p> <pre><code>package net.airpoint.assessments.view { import flash.display.Sprite; import flash.events.MouseEvent; import qnx.ui.buttons.Button; import qnx.ui.core.Container; import qnx.ui.text.Label; import qnx.ui.text.TextInput; import spark.components.View; public class Login extends View { private var usernameLabel:Label; public function Login() { initializeUI(); } public function initializeUI():void { usernameLabel.text = "test"; this.addChild(usernameLabel); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload