I'm getting Flex error #2007, right when the app starts up.
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/getChildIndex()
at mx.core::Container/getChildIndex()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:2411]
at mx.containers::ViewStack/set selectedChild()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\containers\ViewStack.as:557]
at property/parseUrl()[/Users/myname/Documents/Flex Builder 3/property/src/property.mxml:8803]
at property/initBrowserManager()[/Users/myname/Documents/Flex Builder 3/property/src/property.mxml:8749]
at property/___property_Application1_creationComplete()[/Users/myname/Documents/Flex Builder 3/property/src/property.mxml:19]
I'm trying to get deeplinking to work properly. Bhasker Chari on the Adobe Flex forum was kind enough to help me with the code below:
private function parseUrl(e:BrowserChangeEvent = null):void {
var o:Object = URLUtil.stringToObject(browserManager.fragment);
var j:Object = o.view;
var f:String = String(j);
var c:String = f.replace(/-/g,"_");
var t:Container = mainViewStack.getChildByName(c) as Container;
mainViewStack.selectedChild = t;
}
Basically, I take the browserManager.fragment, convert it to a string, replace the dash with an underscore, convert it to a container, and use that to set the the selectedChild on the mainViewStack.
But, when it initializes, it says that there is no child parameter. How can I solve this problem?
Thank you.
-Laxmidi
Okay,
I figured it out. I need to add:
if(t!=null){mainViewStack.selectedChild = t}
else{mainViewStack.selectedIndex = 0}
The children hadn't been created, yet.
Thank you.
-Laxmidi
Related
If some function or library does not have DefinitelyTyped, I know these two ways to stop warnings.
interface Navigator {
getUserMedia: any
}
declare let RTCIceCandidate: any;
But right now, this 3rd-part library Collection2 is used like this:
let ProductSchema = {};
let Products = new Mongo.Collection('products');
Products.attachSchema(ProductSchema);
It give me a warning:
Property 'attachSchema' does not exist on type 'Collection'.
I tried the way below, but it does not work.
interface Collection {
attachSchema: any
}
How can I stop this warning? Thanks
EDIT:
Eric's adding any way solves the problem.
let Products:any = new Mongo.Collection('products');
Products.attachSchema(ProductSchema);
But now a new trouble comes:
let UserSchema = {};
Meteor.users.attachSchema(UserSchema);
Since Meteor.users is built in, so there is no place to add any. How to solve this? Thanks
Thanks for Amid's help. So the way is:
(<any>Meteor.users).attachSchema(UserSchema);
Hey folks, i ve got this issue implementing the Factory method.
Following is the snippet of the the main chart class which calls ChartFactory's method to attain the proper object. I Type Cast chartobject so as to be able to call the Show method;i m apprehensive about that as well.
container = new VBox();
container.percentWidth = 100;
container.percentHeight = 100;
super.media.addChild(container);
chartObject = new ChartBase();
chartObject = ChartFactory.CreateChartObject(chartType);
IChart(chartObject).Show(o);
container.addChild(chartObject);
legend = new Legend();
legend.dataProvider = IChart(chartObject);
container.addChild(legend);
Following is the snippet of ChartFactory's method:
public static function CreateChartObject(subType:String):ChartBase
{
switch(subType)
{
case ChartFactory.AREA_CHART:
return new AreaCharts();
break;
case ChartFactory.COLUMN_CHART:
return new ColumnCharts();
break;
case ChartFactory.PIE_CHART:
return new PieCharts();
break;
default:
throw new ArgumentError(subType + ": Chart type is not recognized.");
}
}
And following is Show method of one of the several Charts type classes: AreaCharts, PieCharts etc. All of which implements IChart Interface.
public function Show(o:ObjectProxy):void
{
var grids:GridLines;
var stroke:SolidColorStroke;
var horizontalAxis:CategoryAxis;
var verticalAxis:LinearAxis;
var horizontalAxisRenderer:AxisRenderer;
var verticalAxisRenderer:AxisRenderer;
grids = new GridLines();
if(WidgetStylesheet.instance.LineChart_ShowGrid)
grids.setStyle("gridDirection", "both");
else
grids.setStyle("gridDirection", "");
stroke = new SolidColorStroke(WidgetStylesheet.instance.LineChart_GridLineColor, WidgetStylesheet.instance.LineChart_GridLineThickness);
grids.setStyle("horizontalStroke", stroke);
grids.setStyle("verticalStroke", stroke);
horizontalAxis = new CategoryAxis();
horizontalAxis.categoryField = o.LargeUrl.Chart.xField;
horizontalAxis.title = o.LargeUrl.Chart.xAxisTitle.toString();
verticalAxis = new LinearAxis();
verticalAxis.title = o.LargeUrl.Chart.yAxisTitle.toString();
horizontalAxisRenderer = new AxisRenderer();
horizontalAxisRenderer.axis = horizontalAxis;
horizontalAxisRenderer.setStyle("tickLength", 0);
horizontalAxisRenderer.setStyle("showLine", false);
horizontalAxisRenderer.setStyle("showLabels", true);
horizontalAxisRenderer.setStyle("fontSize", WidgetStylesheet.instance.ComputeChartAxisFontSize(o.HeadlineFontSize));
verticalAxisRenderer = new AxisRenderer();
verticalAxisRenderer.axis = verticalAxis;
verticalAxisRenderer.setStyle("tickLength", 0);
verticalAxisRenderer.setStyle("showLine", false);
verticalAxisRenderer.setStyle("fontSize", WidgetStylesheet.instance.ComputeChartAxisFontSize(o.HeadlineFontSize));
this.series = this.m_createSeries(o);
this.horizontalAxis = horizontalAxis;
this.horizontalAxisRenderers = [horizontalAxisRenderer];
this.verticalAxis = verticalAxis;
this.verticalAxisRenderers = [verticalAxisRenderer];
this.backgroundElements = [grids];
}
I'm afraid that there is more than one issue with this code. Unfortunately it is not obvious why your chart doesn't show up so you may apply some of advices below and use debugger to analyse the issue.
There is no point in creating ChartBase instance if you are going to change value of chartObject reference in the next line
chartObject = new ChartBase();
chartObject = ChartFactory.CreateChartObject(chartType);
If the API of your charts is IChart your factory should return IChart instead of casting.
public static function CreateChartObject(subType:String):IChart
Make sure that you are returning instances of the correct class from the factory. i.e. that you are returning your subclass of standard PieChart. Generally it's not the best idea to extend the class keeping the same name and just changing the package.
Once again, if you are not sure if the program enters some function use the Flash Builder debugger to check this. I can't imagine development without debugger.
Some thoughts:
you call the Show method, pass it some object but nowhere in that method is any child added to a displayObject. What exactly is Show supposed to do?
a lot of member variables in your classes start with UpperCase. The compiler can easily confuse those with class names, in case your classes are named the same. Bad practice to start variable and function names with capitals.
If your casting an instance to another class or interface fails, you will get a runtime error. Those are easy to debug using the Flash Builder debugger.
Hey ppl..
i found out wat wnt wrng..as olwys it wa "I".
I ve a habit of mkin mock ups secluded from the main project n dn integrate it. So in mock up i hd used an xml whch hd a format slightly diff dn d one being used in the main project.
N i hd a conditional chk to return from the prog if certain value doesnt match, n due to faulty xml i did'nt.
So this more a lexical error than a logical one.
Sorry n Thanx evryone for responding.
What is the preferred way of passing parameters to a Flex application deployed as a .swf and how do I read the parameters from Flex?
I'm looking for the equivalent of passing and reading URL parameters in Flex land.
I like to use FlashVars.
var paramObj:Object = Application.application.parameters;
trace(paramObj['foo']);
public function getQuerystringProperty(property:String):String {
var bm:IBrowserManager = BrowserManager.getInstance();
var oArgs:Object = {};
bm.init("", "");
oArgs = mx.utils.URLUtil.stringToObject(bm.fragment, “&”);
if (oArgs[property])
return oArgs[property].toString();
return "";
}
Gets the QueryString from within Flex (no ExternalInterface).
embed the swf object in an html page and then use external interface. These articles should help you:
http://www.adobe.com/livedocs/flex/2/langref/flash/external/ExternalInterface.html
Flex Examples
How do I determine the URL of the current page from within Flex?
Let's be clear here.
1. If you want the URL of the loaded SWF file, then use one of these.
Inside your application:
this.url;
From anywhere else:
Application.application.url; // Flex 3
FlexGlobals.topLevelApplication.url; // Flex 4
If you are loading your SWF inside another SWF, then keep in mind that the code above will give different values. this.url will return the url of your SWF, where as Application.application.url will give the url of the parent/root SWF.
2. If you want to know the URL that is in the browser address bar, then use one of these.
BrowserManager method(Make sure you have the History.js included in your wrapper html for this to work):
var browser:IBrowserManager = BrowserManager.getInstance();
browser.init();
var browserUrl:String = browser.url; // full url in the browser
var baseUrl:String = browser.base; // the portion of the url before the "#"
var fragment:String = browser.fragment; // the portion of the url after the "#"
JavaScript method:
var browserUrl:String = ExternalInterface.call("eval", "window.location.href");
If you are parsing the url for parameters, don't forget about this useful function:
// parses a query string like "key=value&another=true" into an object
var params:Object = URLUtil.stringToObject(browserURL, "&");
From the Application:
var myUrl:String = Application.application.url;
I searched and came up with this url. I've honestly never used Flex, but it looks like the important part of that document is this:
private function showURLDetails(e:BrowserChangeEvent):void {
var url:String = browserManager.url;
baseURL = browserManager.base;
fragment = browserManager.fragment;
previousURL = e.lastURL;
fullURL = mx.utils.URLUtil.getFullURL(url, url);
port = mx.utils.URLUtil.getPort(url);
protocol = mx.utils.URLUtil.getProtocol(url);
serverName = mx.utils.URLUtil.getServerName(url);
isSecure = mx.utils.URLUtil.isHttpsURL(url);
}
Either way, good luck! :)
Using ExternalInterface (flash.external.ExternalInterface), you can execute Javascript in the browser.
Knowing this, you can call
ExternalInterface.call("window.location.href.toString");
to get the current URL (note that this will be the page url and not the .swf url).
hth
Koen
From the Application, use: this.loaderInfo.loaderURL
to break it apart and use parts of it do:
var splitURL:Array = this.loaderInfo.loaderURL.split('/');
var baseURL:String = "http://"+splitURL[2];
I tried the e:BrowserChangeEvent version and inside my class it didnt or wasnt the appropriate moment for this event to work so in short it didn't work !
Using Application.application.loaderInfo.loaderURL is my preferred solution.
ExternalInterface.call("window.location.href.toString");
I am having problems accessing sub-children of my displayObject. Here is my code:private
function resizeTag(event:MouseEvent):void{
var currTagPos:Number = 1;
var theTagBox:DisplayObject = tagCanvas.getChildAt(currTagPos); //i have confirmed that it exists on the stage and has sub-children
trace(theTagBox.getChildAt(0).width);
}
Essentially I'm trying to get:
tagCanvas.getChildAt(currTagPos).getChildAt(0).width;
but it's not working. Thanks for any guidance you can provide :)
Looks like I needed to call it as a DisplayObjectContainer. I did this instead:
trace((tagCanvas.getChildByName(currTagName) as Canvas).getChildAt(3) as Button);
I found this post which helped me figure it out:
http://www.nabble.com/undefined-method-getChildAt-td19812715.html