Adobe Dreamweaver Forums



Last 10 THreads :         Creating a boundry in the stage... (Last Post : Rob Dillon - Replies : 1 - Views : 2 )           »          Re: Mouse capture won't activate (Last Post : robertnagle - Replies : 0 - Views : 1 )           »          help! my FB3 has gone insane! (Last Post : peteandrus - Replies : 0 - Views : 1 )           »          help! my FB3 has gone insane! (Last Post : peteandrus - Replies : 0 - Views : 1 )           »          How come the html is being displayed, and not the link (Last Post : Skaterstu - Replies : 0 - Views : 1 )           »          Another way to accomplish this (Last Post : Andy-K - Replies : 2 - Views : 3 )           »          HELP! Cannot upload files in DW CS4 (Last Post : dan@hoppernet.org - Replies : 6 - Views : 7 )           »          Adobe Flash 10 kills Wimpy (Last Post : m77ty8uu - Replies : 32 - Views : 208 )           »          How do I unlock all files in site at once (Last Post : Alan - Replies : 1 - Views : 2 )           »          Load library clip into target on stage (Last Post : NedWebs - Replies : 5 - Views : 8 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 10-09-2008, 02:13 AM
SiHoop
 
Posts: n/a
Diggs:
Default Communicating between a class and mxml

I'm making the transition from using lots of code in my projects to writing
classes and am attempting to convert some functions into a class. The code
below is the core of a class that has a problem with the line:
linkStack.selectedChild = teachers_module;

linkStack is the id of a ViewStack in my mxml document, and admin_module and
teachers_module are the ids of two component in that ViewStack.

<comp:Admin id="admin_module" />
<comp:Teachers id="teachers_module"/>
I understand that the class is not communicating with the main file, but
cannot figure out how to pass back the value to the main file. What should I do
differently?

public function EnterAvenue(_enterUsername:String, _userPassword:String){
var params:Object = new Object();
params.username = _enterUsername;
params.password = _userPassword;
service = new HTTPService();
service.url = login_string.login
service.method = "GET";
service.addEventListener("result", httpResult);
service.addEventListener("fault", httpFault);
service.send(params)
return
}
public function httpFault(event:FaultEvent):void {
var faultstring:String = event.fault.faultString;
Alert.show(faultstring);
}
private function httpResult(event:ResultEvent):void{
if(event.result.mydata == "1"){
linkStack.selectedChild = admin_module;
}
if(event.result.mydata == "2"){
linkStack.selectedChild = teachers_module;
}
}



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-09-2008, 02:26 AM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Communicating between a class and mxml


"SiHoop" <webforumsuser@macromedia.com> wrote in message
news:gcjloj$nqb$1@forums.macromedia.com...
> I'm making the transition from using lots of code in my projects to
> writing
> classes and am attempting to convert some functions into a class. The code
> below is the core of a class that has a problem with the line:
> linkStack.selectedChild = teachers_module;


I think this is a Q3
http://www.magnoliamultimedia.com/fl...s_Flex_FAQ.pdf
but you may also want to check Q5 as well.

HTH;

Amy


Reply With Quote
  #3 (permalink)  
Old 10-09-2008, 03:53 AM
SiHoop
 
Posts: n/a
Diggs:
Default Re: Communicating between a class and mxml

I solved the initial problem-- still learning to pass objects to the class! But
now Flex is telling me that I have a null object reference which I'm almost
certain is caused by the following line in my class:
linkStack.selectedChild = admin_module;

linkStack is the ViewStack which has been properly imported and declared in
the class, but I think it's having trouble with admin_module which is the id of
the component that I'm attempting to link to. I assume that it was able to
'see' the object when the code was in the function, but now it is probably
undeclared and I'm not sure what to do about that. If that correct, how would I
declare such a variable? The line of code below is from the original mxml file
that I'm trying to connect to.

<comp:Admin id="admin_module" />



Reply With Quote


  #4 (permalink)  
Old 10-09-2008, 09:23 AM
Greg Lafrance
 
Posts: n/a
Diggs:
Default Re: Communicating between a class and mxml

By default, the children of the ViewStack will not be instantiated until they
are first accessed. You can get around that by setting the ViewStack
creationPolicy="all", but that can affect performance, depending on what the
children contain.

In the past Amy has commented on this same issue, on ways to solve the problem
without resorting to creationPolicy="all". Maybe she will chime in.

Reply With Quote
  #5 (permalink)  
Old 10-09-2008, 01:51 PM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Communicating between a class and mxml


"Greg Lafrance" <webforumsuser@macromedia.com> wrote in message
news:gckb2e$hsv$1@forums.macromedia.com...
> By default, the children of the ViewStack will not be instantiated until
> they
> are first accessed. You can get around that by setting the ViewStack
> creationPolicy="all", but that can affect performance, depending on what
> the
> children contain.
>
> In the past Amy has commented on this same issue, on ways to solve the
> problem
> without resorting to creationPolicy="all". Maybe she will chime in.


That's Q5, as I said. But I think this is a Q3...A component is not in the
same scope as its parent, so if you try to refer to myParent.myProperty,
you're setting yourself up for disappointment.

I think sometimes my replies don't show up on the forum (either that or
people completely and totally ignore my advice for some reason LOL). But
since I often see what looks like one side of a conversation on here, I
think that the NNTP side and the forum side are incompletely connected.

In case my older reply didn't come through, here is the address of the FAQ,
and Q3 and Q5 are the ones you want to look at
http://www.magnoliamultimedia.com/fl...s_Flex_FAQ.pdf


Reply With Quote
  #6 (permalink)  
Old 10-09-2008, 07:00 PM
SiHoop
 
Posts: n/a
Diggs:
Default Re: Communicating between a class and mxml

Hi Amy,
I thought I'd comment on your last post about people not following through
with your feedback. I did read your FAQ, but being a novice found the problem
solution difficult to understand. I find that the best way for me to learn is
to deconstruct code. Very often, a logical, didactic explanation of how to
solve a problem will not work as some of the steps in the solution are too
difficult for me to understand. Once I know how to solve the problem, then I
can understand the explanation!
Please do not take this as criticism, I'm only presenting a 'user' perspective
and trying to explain why it may appear that your efforts are being ignored
(which they are not). As always, many thanks for your help. I've learned a
tremendous amount from you.
BTW, I solved the ViewStack problem by passing a value back from the class and
using that in a conditional statement to pick my container.

Reply With Quote


  #7 (permalink)  
Old 10-09-2008, 08:14 PM
Amy Blankenship
 
Posts: n/a
Diggs:
Default Re: Communicating between a class and mxml


"SiHoop" <webforumsuser@macromedia.com> wrote in message
news:gclgq3$7dp$1@forums.macromedia.com...
> Hi Amy,
> I thought I'd comment on your last post about people not following through
> with your feedback. I did read your FAQ, but being a novice found the
> problem
> solution difficult to understand. I find that the best way for me to learn
> is
> to deconstruct code. Very often, a logical, didactic explanation of how to
> solve a problem will not work as some of the steps in the solution are too
> difficult for me to understand. Once I know how to solve the problem, then
> I
> can understand the explanation!
> Please do not take this as criticism, I'm only presenting a 'user'
> perspective
> and trying to explain why it may appear that your efforts are being
> ignored
> (which they are not). As always, many thanks for your help. I've learned a
> tremendous amount from you.
> BTW, I solved the ViewStack problem by passing a value back from the class
> and
> using that in a conditional statement to pick my container.


I wasn't actually referring to this thread at all. I apologize if it seemed
that way.


Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 02:21 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk