Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
jfizer #1
Included AS file cant access MXML varriables?
I must be missing something here, but when I add in an Action Script file using
the <script source="xxx.as"/> or include "xxx.as"; methods the AS file cant
access variables I declare in the MXML file. Any ideas as to what I'm doing
wrong?
jfizer Guest
-
How to see the .AS file that .MXML file is translated tobefore being compiled to SWF?
I am trying to dynamically load some other Applications in one Application, use ActionScript but not SWFLoader tag, it looks like: ... -
Can I embed external MXML in another MXML file?
Hi - I'm new to this so please bear with me. I'm trying to do something like you do in JSP's with a JSP include where I can import prewritten code... -
how do you access an array in an included/required field?
I have a large array that would be messy to include in the file "main.php" itself and would prefer to include/require it. Say I have the following... -
Problem occurs when included file includes anther file.
The directory structure is as follows: / |-- demo.php |-- inc/ |-- inc1.php |-- inc2.php === file demo.php == <?php require 'inc/inc1.php'; -
[PHP] Problem occurs when included file includes anther file.
Thank you for your reply first. Yes I know I could set include_path either in the php.ini or at runtime.But it's a little bit dirty I think.What... -
miaomm #2
Re: Included AS file cant access MXML varriables?
I don't answers just what happend with me. In one mxml the same include file
works while I save it as another application then all the parameters can not be
seen from the include as file. I can only say it do happen.
miaomm Guest
-
jfizer #3
Re: Included AS file cant access MXML varriables?
For example, the following will generate a "Access of undefined property
myString" error from the AS file.
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationPolicy="all">
<mx:Script>
<![CDATA[
public var myString:String = "Bacon";
include "myAS.as";
]]>
</mx:Script>
</mx:Application>
--------------------------------------------------------------------------------
---------------------------------
// myAS.as
myString="Swine flesh";
jfizer Guest
-
jfizer #4
Re: Included AS file cant access MXML varriables?
In addition, import directives in the MXML don't make it to the Action Script file.
jfizer Guest
-
mab_bond #5
Re: Included AS file cant access MXML varriables?
Try using import instead of include or use this
mab_bond Guest
-
jfizer #6
Re: Included AS file cant access MXML varriables?
[q]Originally posted by: mab_bond
Try using import instead of include or use this[/q]
Huh? Unless I'm missing something, import is for classes not source code files.
jfizer Guest
-
jfizer #7
Re: Included AS file cant access MXML varriables?
This is getting ridiculous. If I cant use include files, what good is this language? My project's over 3k lines so far, am I expected to put that all in one big text file?
jfizer Guest
-
levancho #8
Re: Included AS file cant access MXML varriables?
you can include as file without any problem, and also access all variables that
are declared in including file, but remember you need to access variables from
functions you cant just treat included as file as just one big function
so inside your myAS.as
myString="Swine flesh"; will not work
but
public function myfunction () {
myString="Swine flesh";
}
will work.
levancho Guest
-
jfizer #9
Re: Included AS file cant access MXML varriables?
[q]Originally posted by: levancho
you can include as file without any problem, and also access all variables
that are declared in including file, but remember you need to access variables
from functions you cant just treat included as file as just one big function
so inside your myAS.as
myString="Swine flesh"; will not work
but
public function myfunction () {
myString="Swine flesh";
}
will work.[/q]
Within the same function in my .as file I can access some <MXML> tags by id,
but not others. No rhyme or reason. What finaly made me snap today was trying
to access the HDividedBox by ID that was the parent of the other objects I'd
been working with. Even though the line before and after within the function
accessed the children within the HDividedBox, I got nothing but errors when I
tried to change the properties of the HDividedBox itself.
jfizer Guest
-
mab_bond #10
Re: Included AS file cant access MXML varriables?
Watch your attitude man, nobody wants to steal your code or something like.
We're here the share as a community. Your problem is essentially a Design
Patter, you should learn about OOP, and how to use it. If you wanna access an
external variable you should create a class and define its properties, and so
on... If you wanna develop huge application you ought to read OReilly
ActionScript 3.0 Design Patterns.
mab_bond Guest
-
jfizer #11
Re: Included AS file cant access MXML varriables?
[q]Originally posted by: mab_bond
Watch your attitude man, nobody wants to steal your code or something like.
We're here the share as a community. Your problem is essentially a Design
Patter, you should learn about OOP, and how to use it. If you wanna access an
external variable you should create a class and define its properties, and so
on... If you wanna develop huge application you ought to read OReilly
ActionScript 3.0 Design Patterns.[/q]
Was making no such implication, just saying that I cant share my code as much
as I'd like to since I'm unable to reproduce the problem on smaller projects
(shrug). And I'm not trying to access an external variable. I simply want the
include directive to work as its supposed to. I am using it correctly, but the
results are inconstant and strange. As I've already said, within the same block
of <MXML> I can access some objects by ID but not others. There is no logical
explanation that I can find.
jfizer Guest
-
jfizer #12
Re: Included AS file cant access MXML varriables?
Ugh, this is starting to make my head hurt.
So today I uncommented the line of code that last night was causing errors. No
change was made, but today it works fine. This is without a doubt a problem
with the FLex Builder environment rather then a problem with the source code
I'm working with.
jfizer Guest
-
slaingod #13
Re: Included AS file cant access MXML varriables?
any time you start seeing unexplained behavior in FB it is usually a good idea
to restart FB and then do a clean build of your project. I do so at least twice
a day. FB/Eclipse are very far from perfect, but usually they help more than
they hurt.
slaingod Guest
-
jfizer #14
Re: Included AS file cant access MXML varriables?
[q]Originally posted by: slaingod
any time you start seeing unexplained behavior in FB it is usually a good idea
to restart FB and then do a clean build of your project. I do so at least twice
a day. FB/Eclipse are very far from perfect, but usually they help more than
they hurt.[/q]
I know and I did that yesterday. I really wish I could explain the behavior
I'm seeing. But it's just defying all logic.
However, as a backup, does anyone have a list of what parameters I would need
to use to compile from the command line with the data visualization objects?
Not sure of the class paths off hand.
jfizer Guest
-
levancho #15
Re: Included AS file cant access MXML varriables?
"I can access some objects by ID but not others. There is no logical
explanation that I can find."
if you want to access all objects by id withing same mxml block, than you are
doing something very very wrong, basically that means you are building
application where all objects are siblings and none of them have children,
mxml ids are basically same as variable names, so that means you can only
access mxml objects bt id, ifare defined within same block of mxml, you can
not access mxml objects by id if the are defined outside of the block, or even
inside of the other object which is defined inside your block.
IMHO, best way to help is on example, since your code carries proprietory
nature, you can write a similiar bogus example that shows how you are trying
to access, objects tc ... and what error you are getting ,that should not take
you more than 5 monutes, that way it will be easier for guys to help you
and I think it will finaly save you more frustration and angrey development
days :)
Kind Regards.
levancho Guest
-
jfizer #16
Re: Included AS file cant access MXML varriables?
Not sure I understand what your saying. Of course my MXML objects have parents
and children, but when I had problems I could access the children but not the
parent by ID. In this case it was because I was working on dynamicly resizing
the sections of a HDividedBox and was under the miss impression that I needed
to resize the children rather then setting the divider position.
As for providing an example, the problem is that the issues comes and goes. So
even if I could provide source code, there is no reason to expect that anyone
else would see the problem with the example I could provide.
jfizer Guest
-
levancho #17
Re: Included AS file cant access MXML varriables?
Object A can access its children with ids: (b,c,d) (which is same as by
variable name) because they are part of that object ,so somewhere in object A
there is code :
b = childOne
c = childTwo
d = childThree
thats why objct A can say c.doSomething, b.doSomething else etc ...
but
Object A can not access its parent (f) By id ,because
Object A does not have :
f = parentObject
(although DisplayObject has property called "parent" which is invented for
that reason so one DisplayObject can cascade up the hierarchy to its parent etc
....).
levancho Guest
-
jfizer #18
Re: Included AS file cant access MXML varriables?
[q]Originally posted by: levancho
[Q]Originally posted by: jfizer
Not sure I understand what your saying. Of course my MXML objects have parents
and children, but when I had problems I could access the children but not the
parent by ID..[/Q]
Object A can access its children with ids: (b,c,d) (which is same as by
variable name) because they are part of that object ,so somewhere in object A
there is code :
b = childOne
c = childTwo
d = childThree
thats why objct A can say c.doSomething, b.doSomething else etc ...
but
Object A can not access its parent (f) By id ,because
Object A does not have :
f = parentObject
(although DisplayObject has property called "parent" which is invented for
that reason so one DisplayObject can cascade up the hierarchy to its parent etc
....).
[/q]
You seem to be off on some strange tangent. Its simple, I have for example
MXML as follows...
<mx:HDividedBox id="daBox" width="100%" height="100%">
<mx:Canvas id="daCanvas" label="Canvas 1" width="100%"
height="100%" backgroundColor="#FFFFCC">
<mx:Label id="daText" text="Add components here"
fontWeight="bold"/>
</mx:Canvas>
<mx:Canvas label="Canvas 2" width="100%" height="100%"
backgroundColor="#99CCFF">
<mx:Label text="Add components here" fontWeight="bold"/>
</mx:Canvas>
</mx:HDividedBox>
Now my action script code could change the properties of daCanvas or daText
but not daBox. At least until it magically started working this morning (well
yesterday morning by now). At a guess, this is a problem with the syntax
checker, but because its intermittent its hard to really check.
jfizer Guest
-
levancho #19
Re: Included AS file cant access MXML varriables?
<mx:HDividedBox id="daBox" width="100%" height="100%">
<mx:Canvas id="daCanvas" label="Canvas 1" width="100%" height="100%"
backgroundColor="#FFFFCC">
<mx:Label id="daText" text="Add components here" fontWeight="bold"/>
</mx:Canvas>
<mx:Canvas label="Canvas 2" width="100%" height="100%"
backgroundColor="#99CCFF">
<mx:Label text="Add components here" fontWeight="bold"/>
</mx:Canvas>
</mx:HDividedBox>
----------
IT IS NOT POSSIBLE to access daCanvas and daText by just their Id from
same function of same included AS file eitheryou can not access them at all,
or can access one or the other, not both.
I suggest you read developer Guide, at :
[url]http://www.adobe.com/support/documentation/en/flex/[/url]
it will make it clear.
levancho Guest
-
mab_bond #20
Re: Included AS file cant access MXML varriables?
Levancho why do you say that isn't possible to access daCanvas and daText?
mab_bond Guest



Reply With Quote

