Solved

this.parentDocument  for actionscript file

Posted on 2011-09-08
10
736 Views
Last Modified: 2012-05-12
hi guys

I have a line like this
var searchString : String = (this.parentDocument as TradeLookUp).parseSearchText();

TradeLookUp is mxml file.

I have an actionscript file CustomLookup

but when i give
var searchString : String = (this.parentDocument as CustomLookup).parseSearchText();
i get an error.
i guess this.parentDocument  works with mxml
any idea whats the solution

thanks

0
Comment
Question by:royjayd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 29

Expert Comment

by:dgofman
ID: 36505973
Are you using CustomLookup in your MXML

Can be two problems:
1) parentDocument is not instance of CustomLookup
add one line above trace(parentDocument );
2) in CustomLookup.as file you don't have public function parseSearchText
you can validate by:
var lookup: CustomLookup= this.parentDocument as CustomLookup;
trace(lookup.hasOwnProperty("parseSearchText"));

0
 

Author Comment

by:royjayd
ID: 36506749
actually i am getting an error  
on this line
var searchString : String = (this.parentDocument as CustomLookup).parseSearchText();
                        

The error is
TypeError: Error #1009: Cannot access a property or method of a null object reference.
0
 
LVL 29

Expert Comment

by:dgofman
ID: 36506794
Did you read what I am suggestion?

replace by

trace("Is CustomLookup=" + this.parentDocument is CustomLookup);
var lookup: CustomLookup= this.parentDocument as CustomLookup;
trace("Is accessible to parseSearchText="+lookup.hasOwnProperty("parseSearchText"));
var searchString : String = lookup.parseSearchText();

0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:royjayd
ID: 36525250
Hi i tried this and getting this responce in console

trace("Is CustomLookup=" + this.parentDocument is CustomLookup);
false

var lookup: CustomLookup= this.parentDocument as CustomLookup;
trace("Is accessible to parseSearchText="+lookup.hasOwnProperty("parseSearchText"));
getting error here: TypeError: Error #1009: Cannot access a property or method of a null object reference.

var searchString : String = lookup.parseSearchText();

thanks
0
 
LVL 29

Expert Comment

by:dgofman
ID: 36525369
You got answer in first trace. You are customhouse to wrong class. Check what type of parentDocument
0
 

Author Comment

by:royjayd
ID: 36525879
yeah.Actually this is what i am doing

In CustomLookup.as i am using this code
/**
 * Prepares the datagrid column from dataFieldCollection.
 * */
public function createDataGridColumns () : void {
columns = new Array();
for each (var object : Object in dataFieldCollection){
var col : DataGridColumn = new DataGridColumn();
col.headerText = object.headerText;
col.dataField = object.dataField;
col.width = object.width;
if ( object.dataField != CHECKHBOX ) {
col.itemRenderer = new ClassFactory ( org.ms.views.components.renderers.DataLabelForGrid );
} else {
col.itemRenderer = new ClassFactory ( org.ms.views.components.renderers.SelectCheckBox );
}
columns.push( col );
}
dataGrid.columns = columns;
}



and in DataLabelForGrid.mxml  i have

<?xml version="1.0" encoding="utf-8"?>
<mx:Label xmlns:mx="http://www.adobe.com/2006/mxml">
      
<mx:Script>
<![CDATA[
import mx.controls.dataGridClasses.DataGridListData;
import mx.core.Application;
import org.ms.views.components.CustomLookup;
override public function set data ( value : Object ) : void {
super.data = value;
var strData : String = value as String;                        
var labelString : String = value[DataGridListData(listData).dataField] as String;
trace("parent doc=" + this.parentDocument);  
//here i want this.parentDocument to  be CustomLookup
Any idea how i can make this.parentDocument as CustomLookup ?

if (searchString.text = "jay") {
this.setStyle( "color", "yellow" );
}  
}
]]>
</mx:Script>
</mx:Label>
0
 
LVL 29

Expert Comment

by:dgofman
ID: 36525933
In DataLabelForGrid.mxml create public variable

public var lookup:CustomLookup;

Now modify you CustomLookup.as

if ( object.dataField != CHECKHBOX ) {
var cf:ClassFactory = new ClassFactory ( org.ms.views.components.renderers.DataLabelForGrid );
cf.properties = {lookup:this};
col.itemRenderer = cf;
} else {


That should assign lookup variable during constractor

now you can use  "lookup" variable  in your DataLabelForGrid.mxml

I didn't compile but should work
0
 

Author Comment

by:royjayd
ID: 36526147
nice, but i did not understand how it works :)
cf.properties = {lookup:this};  what does this line do ?

>>That should assign lookup variable during constractor
so lookup is assigned to CustomLookup in constructor of CustomLookup ?

thanks
0
 
LVL 29

Accepted Solution

by:
dgofman earned 500 total points
ID: 36526285
You can always find any answer what am I doing in Adobe documentation

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/ClassFactory.html
0
 

Author Comment

by:royjayd
ID: 36529229
THANKS!
0

Featured Post

Don't Miss ATEN at InfoComm 2017!

Visit booth #2167 to see the  new ATEN VM3200 32 x 32 Modular Matrix Switch. Other highlights include the VE8950 4K HDMI Over IP Extender, VS1912 12-Port DP Video Wall Media Player  and VK2100 ATEN Control System. Register now with Free Pass Code ATEN288!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Flash builder 101 tutorial 3 456
Transfer of mobile action script package to mobile mxml code 9 433
html into FLEX 3 281
establish a .net -flex website with existing code 3 340
First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Configuring Remote Assistance for use with SCCM
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question