Mxml vs as components
@see code attached
if you run application and will click LMP, you'll see
blinking. Comment setting dimensons and blinking will disappear.
Therefore, have a look at components. One is as component and
the second one is mxml. remove comments for adding to display list
for the second mxml components. It's blinking again.
IMHO, the difference is translating mxml to as. But notice
about scrollers.
Any ideas? :) May be workaround ?
Thanks a lot
Hi,
I could not find code attached. MXML is not converted at runtime, it is converted to ActionScript and is compiled to SWF when you compile your project. Sharing the code to reproduce this behavior will help in solving the problem.
Hope this helps.
Similar Messages
-
Passing VARs between MXML Application and MXML components!
Hi,
I'm trying to pass a variable between the MXML Application and the MXML Component with ValueObjects.
But when i call the variable on the MXML Component it is null!
ValueObject Class Code:
package valueObjects
[Bindable]
public class MyGlobalVars
public var NomeGaleria: String;
public function MyGlobalVars()
MXML Application Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:comp="components.*" layout="vertical" height="100%" width="100%" >
<mx:Script>
<![CDATA[
import valueObjects.MyGlobalVars;
import mx.managers.PopUpManager;
import mx.core.Container;
[Bindable]
public var nomeGaleria:MyGlobalVars;
private function AbreGaleria():void{
nomeGaleria=new MyGlobalVars();
nomeGaleria.NomeGaleria = "Moda";
PopUpManager.addPopUp(new galeriaImagens(),this,true);
]]>
</mx:Script>
<mx:Panel height="673" width="839" verticalAlign="middle" borderStyle="none" layout="absolute">
<mx:Canvas id="SMGaleria" width="815" height="30" x="2" y="98"">
<mx:LinkButton x="474" y="5" label="moda" click="AbreGaleria()"/>
</mx:Canvas>
<mx:ViewStack id="content" height="440" width="815" borderStyle="none" x="2" y="128">
<comp:galeriaImagens id="GaleriaImagens" x="0" y="5" strGaleria="{nomeGaleria}"/>
</mx:ViewStack>
</mx:Panel>
</mx:Application>
MXML Component Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
showCloseButton="true" creationComplete="CenterMe()" backgroundColor="#000000" xmlns:components="components.*" >
<mx:Script>
<![CDATA[
import valueObjects.MyGlobalVars;
import mx.controls.Alert;
[Bindable]
public var strGaleria:String;
private function CenterMe(): void{
Alert.show(strGaleria);
]]>
</mx:Script>
</mx:TitleWindow>
On the MXML component the value of strGaleria is null! It would not have to be: Moda??You may need to change your code as follows:
<comp:galeriaImagens id="GaleriaImagens" x="0" y="5" strGaleria="{nomeGaleria.NomeGaleria}"/>
Previously you had set strGaleria to the value of the object, not the string within the object.
But I think you will still have a problem because function AbreGaleria will not be called until the user clicks the link button, and only then will NomeGaleria have a value, so I would set a default value as follows, otherwise at app launch it will be null:
public var NomeGaleria: String = "";
or if that does not work
public var NomeGaleria: String = " ";
Another possible problem is that you are calling this code at the component creationComplete, but the LinkButton has not been clicked yet, so the value object string value has not been set, so the alert will not display anything:
private function CenterMe():void{
Alert.show(strGaleria);
I think you need to reorganize some things here.
If this post answers your question or helps, please mark it as such. -
Architecting an Application With MXML Components
I have an application that has gotten lengthy and I want to
simplify it by architecting the Main Application with custom MXML
Components. The application as it is currently architected works
perfectly.
Currently, the application consists of "Canvas" containers
along Top and Left Side holding Navigation Buttons. The main
(changing) sections of the application will consist of a
"ViewStack" container holding a number of "Canvas" containers
stacked on top of one another. The navigation buttons along the top
and left side, when clicked, display in turn the content of each of
the several stacked "Canvas" containers. Because of the number of
stacked "Canvas" containers within the "ViewStack" and the content
of each, the main Application source code has become very long and
unwieldy, thus the need to use custom components for each of the
"Canvas" containers in the "Stack" and referencing them in the main
Application page.
I have tried several times to get this to work and I need to
clarify a couple of things.
1) After setting up custom components for the several
"Canvas" containers that are now in the "ViewStack" container, do I
first need to set up a custom component for the "ViewStack"
container with its own name space?
2) If the answer to 1) above is Yes then do I then reference
each of the custom components for the "Canvas" container with their
own name space designation within the "ViewStack" reference within
the main Application?
In the event I am completely off base then I would appreciate
any suggestions. If you wish I would be happy to email you the
current application page.
Thanks,
Joe
joe kHere is some code for an app built with components. You can
see how the pieces talk to each other a bit.
------------------------- ViewStack1.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:comp="components.*"
layout="vertical" width="100%" height="100%" >
<comp:TopBar />
<mx:HBox width="100%" height="100%">
<comp:LeftBar />
<mx:VBox width="100%" height="100%">
<mx:ViewStack id="myViewStack" borderStyle="none"
width="100%" height="100%">
<mx:VBox id="home" width="100%">
<comp:MainIntroText />
<mx:HRule width="50%" height="3"
strokeColor="0xCC3333"/>
<comp:MainSecondaryText />
<mx:HRule width="50%" height="3"
strokeColor="0xCC3333"/>
<comp:MainFinalText />
</mx:VBox>
<mx:VBox id="about" width="100%">
<comp:About />
</mx:VBox>
<mx:VBox id="contact" width="100%">
<comp:Contact />
</mx:VBox>
</mx:ViewStack>
</mx:VBox>
</mx:HBox>
</mx:Application>
------------------------------- About.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:VBox width="65%">
<mx:Text fontSize="14" width="100%" text="This page tells
you about us." />
</mx:VBox>
</mx:HBox>
----------------------------------- Contact.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:VBox width="65%">
<mx:Text fontSize="14" width="100%" text="This page tells
you how to contact us." />
</mx:VBox>
</mx:HBox>
------------------- LeftBar.mxml -------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="200" height="100%">
<mx:LinkButton label="Adobe Labs - Flex"
click="navigateToURL(new URLRequest('
http://labs.adobe.com/technologies/flex'),
'_blank');"/>
<mx:Spacer height="20"/>
<mx:Label fontSize="16" text="Flex Blogs"/>
<mx:LinkBar direction="vertical" width="90%"
itemClick="navigateToURL(new URLRequest(event.item.data),
'_blank');">
<mx:Object label="Adobe Flex Team Blog" data="
http://weblogs.macromedia.com/flexteam/"/>
<mx:Object label="Flex Blog Aggregator" data="
http://www.allyourflexarebelongtous.com/"/>
<mx:Object label="Adobe Flex Blog Aggregator" data="
http://weblogs.macromedia.com/mxna/index.cfm?query=byCategory&categoryId=5&categor yName=Flex"/>
</mx:LinkBar>
<mx:Spacer height="20"/>
<mx:Label fontSize="16" text="Example Flex Apps"/>
<mx:LinkBar direction="vertical" id="addlRscList"
width="90%" itemClick="navigateToURL(new
URLRequest(event.item.data), '_blank');">
<mx:Object label="Adobe Flex Store" data="
http://www.adobe.com/devnet/flex/samples/flex_store_v2/"/>
<mx:Object label="Adobe Dashboard Example" data="
http://examples.adobe.com/flex2/inproduct/sdk/dashboard/dashboard.html"/>
<mx:Object label="Buzzword Word Processor" data="
http://preview.getbuzzword.com/?s=true"/>
<mx:Object label="Adobe Style Explorer" data="
http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html"/>
<mx:Object label="Adobe Component Explorer" data="
http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html"/>
</mx:LinkBar>
</mx:VBox>
----------------------- MainFinalText.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:Text width="100%" fontSize="12"
text="Here is the final text I want to show you." />
</mx:VBox>
--------------------------- MainIntroText.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:Text width="100%" fontSize="12"
text="Here is the main text I want to show you." />
</mx:VBox>
----------------------- MainSecondaryText.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:Text width="100%" fontSize="12"
text="Here is the secondary text I want to show you." />
</mx:VBox>
--------------- TopBar.mxml --------------------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%">
<mx:Script>
<![CDATA[
private function goToViews(view:String):void {
if(view == "home"){
this.parentApplication.myViewStack.selectedChild=this.parentApplication.home;
if(view == "about"){
this.parentApplication.myViewStack.selectedChild=this.parentApplication.about;
if(view == "contact"){
this.parentApplication.myViewStack.selectedChild=this.parentApplication.contact;
]]>
</mx:Script>
<mx:LinkButton label="MySnazzyLogo" fontSize="20"
click="goToViews('home');" />
<mx:VBox width="100%">
<mx:HBox width="100%">
<mx:Spacer width="100%" />
<mx:LinkBar fontSize="14"
itemClick="goToViews(String(event.item.data));">
<mx:Array>
<mx:Object label="About Us" data="about"/>
<mx:Object label="Contact Us" data="contact"/>
</mx:Array>
</mx:LinkBar>
</mx:HBox>
<mx:HBox width="100%">
<mx:Spacer width="150" />
<mx:Label fontSize="25" text="Here is Some Additional
Text" />
</mx:HBox>
</mx:VBox>
</mx:HBox> -
I have a series of components that I assign various values (text) to. We added a TabNavigator to reduce the vertical space that was being taken and now the components within it are null and won't accept the values that they did before the TabNavigator was added.
I"m assuming that with the TabNavigator comes a different visibility. Within the mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:DHSComp="components.*"
initialize="setInitAccessible();"
applicationComplete="setInitLanguage();"
backgroundColor="#dedacf"
layout="absolute"
borderStyle="inset"
borderThickness="2"
paddingLeft="10"
paddingRight="10"
paddingTop="10"
paddingBottom="10"
height="100%"
width="100%"
verticalScrollPolicy="on">
I don't know of an event that is after "applicationComplete". The call is to:
<mx:Script>
<![CDATA[
public function setInitLanguage():void {
resetEnglish();
public function setInitAccessible():void {
getXMLURL();
accessibleSet();
]]>
</mx:Script>
Within the reset:
public function resetEnglish():void {
// all "get" are in DHSclasses/FSLangEnglish.as
pageSNAPText = English.getPageSNAPText();
... // these work OK
if (currentState != "Result") {
resetEnglishBase(); // scripts/FSLangEngBase.as
The problem comes up in the next call. The prior one and the next one are both scripts included in the mxml file:
public function resetEnglishBase():void {
// reset inputform (base) to English
// all "get" are in DHSclasses/FSLangEnglish.as
householdInformationPanel.title = English.getHouseholdInformationLabel();
householdInformationPanel.toolTip = English.getHouseholdInformationTT();
The "householdInformationPanel.title" shows as a null when the TabNavigator is included and not when it is not.
The question becomes how do I get the title to work when a TabNavigator is included?You, sir, are a gentleman and a scholar. That worked - thanks!
-
How to pass a value from 1 mxml componet to the another mxml componet
I have created 3 mxml components. I am using 1st component as
a container component for other 2 components mean[ inside 1st
component i have placed 2 other components]. now i want to pass
selectedvalue from 1 component to another component.
say 1st component is
MyFirstComponent.mxml
2nd component is
MySecComponent.mxml
3rd component is
MyThirdComponent.mxml
now i have place 2nd & 3rd component in 1st component.
whenever i select an item from dropdown in 2nd component i want to
set/pass that selectedvalue to 3rd component public variable. how
can i achieve this.
MySecondComponent.mxml
[code]
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:salesforce="
http://www.salesforce.com/"
creationComplete="login()">
<mx:ComboBox x="102" y="26" id="ddlDepartmentName"
cornerRadius="2" height="20"
fontWeight="bold" width="148"/>
</mx:Canvas>
[/code]
MyThirdComponent.mxml
[code]
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:salesforce="
http://www.salesforce.com/"
creationComplete="login();">
<mx:Script>
<![CDATA[
import SubComponents.Department.DepartmentSummary;
public var departmentID:String = 10;
]]>
</mx:Script>
</mx:HBox>
[/code]
right now i am using hardcoded departmentID in 3rd component,
i want to remove the hardcoded value and i want to set the value
from 2nd components' on selectionChange.
When i select department Name from the comboBox which is
created in 2nd component i want to get the value in 3rd component.
how can i achive this..
want to set the departmentID in 3rd component to the
ddlDepartmentName.selectedValue in 2nd component. when i change the
selected value in 2nd component i want to display the department
information in 3rd component after setting the departmentID
Waiting for your valuable answer.This code seems to work:
------------------ MyThirdComponent.mxml -------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:salesforce="
http://www.salesforce.com/">
<mx:Script>
<![CDATA[
[Bindable]
public var departmentID:String = new String();
]]>
</mx:Script>
<mx:Text text="{departmentID}"/>
</mx:HBox>
------------------------- MySecondComponent.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:salesforce="
http://www.salesforce.com/">
<mx:Script>
<![CDATA[
public function changeHandler():void{
this.parentApplication.my3rd.departmentID =
ddlDepartmentName.selectedLabel;
]]>
</mx:Script>
<mx:ComboBox x="102" y="26" id="ddlDepartmentName"
cornerRadius="2" height="20"
fontWeight="bold" width="148" change="changeHandler()">
<mx:ArrayCollection>
<mx:String>Bananas</mx:String>
<mx:String>Apples</mx:String>
<mx:String>Oranges</mx:String>
</mx:ArrayCollection>
</mx:ComboBox>
</mx:Canvas>
----------------------- Test.mxml
<?xml version="1.0"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:comp="components.*" creationComplete="init()">
<mx:Script>
<![CDATA[
public function init():void{
my3rd.departmentID = my2nd.ddlDepartmentName.selectedLabel;
]]>
</mx:Script>
<comp:MyThirdComponent id="my3rd"/>
<comp:MySecondComponent id="my2nd"/>
</mx:Application> -
Change a state in main.mxml from a script in another mxml
Hi,
i'm having some trouble with my application, let's say i have the main application file called MAIN.MXML
in wich i have set different States, and have different forms.
now i have a form called loginForm which contains the textInput item for Login and Password, i also have a link Need to Register
which onClick will change the state to show in the same panel a different form registerForm (with the relevant textInput items)
now the MAIN.MXML includes a custom component called <comp: NetworkManager /> which includes all the logic scripts and MXML
tags to create and manage an HTTPService request to a PHP Server.
when the user click on the Login button, this will call a function included in the main.as script (imported in MAIN.MXML) which
will call a function in the script within NetworkManager.MXML passing all the form data.
in NetworkManager.MXML the script will create an XML message, will send to the PHP Server and wait the response... if this comes
true the user is authenticated, otherwise is not.
so far so good, i get the message sent, the correct response back. Now i want to hide the form in MAIN.MXML and put something like
Welcome firstName lastName!! instead. But i don't know how to do it. If i try to access the states in MAIN.MXML from the NetworkManager.MXML
i'll get all sort of errors which i don't have it here with me.
I know this sounds like a newbie question, and it really is ... any taker?
your help is much appreciated.
thanks
T.Hi,
i've tried RemoveChild but i get an error like:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::$removeChild()[C:\autobuild\3.2.0\frameworks\p rojects\framework\src\mx\core\UIComponent.as:5096]
at mx.core::Container/removeChild()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\ core\Container.as:2274]
at components::NetworkManager/sendUserAuthHandler()[C:\Documents and Settings\Tom\My Documents\flex_prj\Shoppy\src\components\NetworkManager.mxml:182]
at components::NetworkManager/serverHandler()[C:\Documents and Settings\Tom\My Documents\flex_prj\Shoppy\src\components\NetworkManager.mxml:98]
at components::NetworkManager/__serverRPC_result()[C:\Documents and Settings\Tom\My Documents\flex_prj\Shoppy\src\components\NetworkManager.mxml:290]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\autobuild\3.2.0\framewor ks\projects\rpc\src\mx\rpc\http\mxml\HTTPService.as:290]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.2.0\frameworks\ projects\rpc\src\mx\rpc\AbstractInvoker.as:193]
at mx.rpc::Responder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responde r.as:43]
at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\ AsyncRequest.as:74]
at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\s rc\mx\messaging\channels\DirectHTTPChannel.as:403]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
who is the caller of loginForm then? i've tried with Application.application.loginForm but i do get the same error though.
loginForm is contained in a Canvas item, is it the caller? or who else?
thanks
T. -
Failed to open design mode for .mxml document
Hi,
I have recently installed flash builder 4 plugin to eclipse galilo. I am working on a project which uses flex SDK. Using eclipse flash perspective when try to open a .MXML file, the design tab is throwing an error message on the screen "An unknown item declared as root of your MXML document. Swoitch to source mode to correct it".
Under Components tab of eclipse I can see the following error:
Could not create the view: An unexpected exception was thrown.
java.lang.NullPointerException
at com.adobe.flexbuilder.codemodel.internal.design.ComponentCategoryList.getCustomComponents Filtered(ComponentCategoryList.java:207)
at com.adobe.flexbuilder.mxml.editor.views.components.ComponentsView$ViewContentProvider.get Elements(ComponentsView.java:339)
at org.eclipse.jface.viewers.StructuredViewer.getRawChildren(StructuredViewer.java:959)
at org.eclipse.jface.viewers.ColumnViewer.getRawChildren(ColumnViewer.java:703)
at org.eclipse.jface.viewers.AbstractTreeViewer.getRawChildren(AbstractTreeViewer.java:1330)
at org.eclipse.jface.viewers.TreeViewer.getRawChildren(TreeViewer.java:390)
Below is my mxml file content:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical" backgroundColor="white" width="100%" height="100%"
paddingBottom="6" paddingLeft="6" paddingRight="6" paddingTop="6"
keyUp="Mediator.instance.debugLogic.handleDebugToggle(event)"
applicationComplete="Mediator.instance.init(this, ID_TABS)">
<mx:Script><![CDATA[
import metasearch.main.Mediator;
]]></mx:Script>
<mx:TabNavigator id="ID_TABS"
backgroundColor="#cccccc" width="100%" height="100%"
paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10">
</mx:TabNavigator>
</mx:Application>
Please tell me what's wrong with the above document.thank you! I'll let you know if it worked!
the only problem is that none of my tweens and actions are correct. -
How to include mxml in a panel
hi,
I have a set of mx:Panels
The content to be displayed inside each panel is structured
in an mxml file.
How do i reference or place this mxml file inside the panels.
Thanks,
Lucky---------------------------- components/MyVBox1.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%" height="100%">
<mx:Button id="myButton1" label="MyButton1"/>
<mx:Button id="myButton2" label="MyButton2"/>
</mx:VBox>
---------------------------- components/MyVBox2.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%" height="100%">
<mx:CheckBox id="myCheckbox1" label="MyCheckbox1"
selected="true"/>
<mx:CheckBox id="myCheckbox2" label="MyCheckbox2"
selected="false"/>
</mx:VBox>
-------------------- SimpleExampleApp.mxml
<?xml version="1.0"?>
<!-- menus/EventListener.mxml -->
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:comp="components.*" initialize="init()" width="500"
height="500">
<mx:Script>
<![CDATA[
import components.MyVBox2;
private function init():void{
myPanel2.addChild(new MyVBox2());
]]>
</mx:Script>
<mx:Panel id="myPanel1" backgroundColor="#DB8686"
width="200" height="200">
<comp:MyVBox1 />
</mx:Panel>
<mx:Panel id="myPanel2" backgroundColor="#9F86DB"
width="200" height="200"/>
</mx:Application> -
Breaking up an App into components
I have an App in deployment which displays a dashboard
program divided into several tabs, one tab contains a treemap,
another has four charts, another has one big chart, another has
five dials, etc. etc. currently this is all coded into one big App.
What I want to do now is break this up into either MXML or AS
components so that it will be more managable and more modular. I
want to make a 'shell' master program with the tabs, and then
import the other pieces as modules.
I have managed to separate out one of my most complex pieces
from my original main App, one of the Treemaps, and I want to now
import that as a component of my "shell". Can someone reccomend a
technote or a web page I could look at to learn how to do this? I'd
also like to learn some things like how do you 'talk to' variables
within a particular component that you import in, or is that even
possible?
M.Is this even the best practice? Should you break an app into
components? Or is it better to just leave it all in one App?
I found this example of using code behind to extent the
ActionScript class, is this the best way to aproach breaking an app
up?
http://www.adobe.com/devnet/flex/quickstart/building_components_using_code_behind/ -
Call Function From MXML Component
I am using MXML to create components that I use within my
application. I have one MXML file that contains a list with a
custom itemRenderer that is in another MXML file. I have an
actionscript file with a function that I want to call from the
itemRenderer.
If I call the function from my main application, everything
works fine. If I try to call it from one of the other MXML files, I
get a 1180 Call to a possibly undefined function error.
Is there a special way that I need to use to call the
function?
The main MXML file is in the root directory, the actionscript
file is in a folder called functions, and the MXML files are in a
folder called components.
Thank you for any help.I was able to figure out my problem. It was just a simple
typo of including the wrong file in a Script tag. However, this
caused more issues and I ended up having to rewrite a large section
of code to get everything working.
Thank you for your help. -
Breaking up large Apps into components
Hello, I have a large application that I need to break up
into components. I have been trying to find information on how to
do this, however, to no real avail. My application will have
components that have states so that when the user selects from the
menu bar the component state will show. Does anyone know how I can
get my XMLlist view state to show the external component state when
selected?
Thanks
LZViewstacks might work, here is an example:
------------------------------ ViewStack.mxml
<?xml version="1.0"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:comp="components.*">
<mx:Script>
<![CDATA[
private function selectPortal(event:Event):void {
if(cmbx.selectedItem.data == "home"){
portals.selectedChild = home;
if(cmbx.selectedItem.data == "hr_portal"){
portals.selectedChild = hr_portal;
if(cmbx.selectedItem.data == "is_portal"){
portals.selectedChild = is_portal;
if(cmbx.selectedItem.data == "pay_portal"){
portals.selectedChild = pay_portal;
]]>
</mx:Script>
<mx:ApplicationControlBar width="100%">
<mx:Label text="Select an intranet portal: "
fontSize="12"/>
<mx:ComboBox id="cmbx" change="selectPortal(event)">
<mx:Object label="XYZ Intranet Home Page"
data="home"/>
<mx:Object label="Human Resources Portal"
data="hr_portal"/>
<mx:Object label="Information Services Portal"
data="is_portal"/>
<mx:Object label="Payroll Portal" data="pay_portal"/>
</mx:ComboBox>
</mx:ApplicationControlBar>
<mx:ViewStack id="portals" width="100%" height="100%">
<mx:Panel width="100%" height="100%"
horizontalAlign="center"
backgroundColor="#ccffcc" id="home">
<mx:Text text="Welcome to the XYZ Corporate Intanet"
fontSize="20"
color="blue"/>
</mx:Panel>
<comp:HumanResources id="hr_portal"/>
<comp:InformationServices id="is_portal"/>
<comp:Payroll id="pay_portal"/>
</mx:ViewStack>
</mx:Application>
---------- components/HumanResources.mxml ------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns="*" xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%" height="100%" horizontalAlign="center"
backgroundColor="red">
<mx:Text text="Human Resources Portal" fontSize="20"
color="blue"/>
</mx:Panel>
---------- components/InformationServices.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns="*" xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%" height="100%" horizontalAlign="center"
backgroundColor="purple">
<mx:Text text="Information Services Portal" fontSize="20"
color="blue"/>
</mx:Panel>
---------- components/Payroll.mxml ------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns="*" xmlns:mx="
http://www.adobe.com/2006/mxml"
width="100%" height="100%" horizontalAlign="center"
backgroundColor="gray">
<mx:Text text="Payroll Portal" fontSize="20"
color="blue"/>
</mx:Panel> -
Creating Flex applications without MXML but with AS3
To me it seems logical that if I want to build an application
I should use AS3 to create reusable components, classes, the
layout, etc.
.. however, searching around on the web I exclusively find
Flex tutorials and examples using MXML. This is also true for the
books (e.g. Adobe Flex 2 - Training from the source") -- why is
this?
Is it wrong of me to think it'd be best to create everything
in AS3? Do anyone have links to tutorials etc. where they use AS3
to build Flex applications?Although I have not seen tutorials about this I did create a
test app using the following approach:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:lib="components"
width="100%"
height="100%"
creationComplete="initGrid()"
scroll="false"
>
<mx:Script>
<![CDATA[
..... AS 3 code here to create/populate app - datagrid in my
case
]]>
</mx:Script>
<mx:VBox id="_box" width="100%">
<mx:Button id="hideShowCols" label="Hide Empty Columns"
click="doColumnAction();"/>
<mx:DataGrid id="delinquenciesGrid"
alternatingItemColors="[#cce6ff, #e8ffff]"
alpha="0.5"
lockedColumnCount="3"
allowMultipleSelection="true"
rowCount="20"
headerColors="[#cccccc]"
fontFamily="Arial"
visible="false"
preinitialize="detectClick();"
>
</mx:DataGrid>
</mx:VBox>
</mx:Canvas>
Even the data grid does not need to be "declared" in MXML, it
was just a faster way to do it for me - you could do
canvas_id.addChild(...) any element/item that you create in
AS3.... or in my case i was doing _box.addChild(newGrid) -
How do I pass a value from a selected datagrid row to a popup
I am working on a project tracking application in flex and need to pass the value of one of the rows from the datagrid to a popup. We have a screen with 2 data grids. The first datagrid lists the projects, their start, and end date and the project owner. The datagrid below the first datagrid lists the tasks for that specific project listed in the datagrid above. When you click on the project name above, the datagrid below is populated with the tasks. Within the tasks datagrid are start and end date boxes.
What I need to do is be able to pass the project ID from the original datagrid into a popup that is called when a user changes the date of a project task. The popup is designed to submit a reason for why the user is changing the date on the task. In short, when they submit a reason, I need the project id passed from the datagrid into the popup so when submit is clicked, the proper row in the DB table is update via a CFC. Thank you.I tried that, but when I try to build the project, I get the error that there is a call to an undefined value. Here is code:
Project Component:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
width="100%" height="100%" creationComplete="init();" xmlns:mxml="components.mxml.*">
<mx:Script>
<![CDATA[
import mx.events.ListEvent;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.rpc.events.ResultEvent;
import mx.managers.PopUpManager;
import mx.core.IFlexDisplayObject;
import components.mxml.NewProject;
import components.mxml.NewTask;
import components.mxml.dateChangeNotice;
import mx.controls.Alert;
private function init():void{
roGetData.getProjects();
//roGetData.getTasks();
private function projectClick(event:ListEvent):void{
//Alert.show(dgProjects.selectedItem.projectID);
roGetData.getTasks(dgProjects.selectedItem.projectID);
private function refreshProjects(event:MouseEvent):void{
roGetData.getProjects();
private function ResultEvent_Projects(event:ResultEvent):void{
dgProjects.dataProvider = event.result;
private function ResultEvent_Tasks(event:ResultEvent):void{
adgTasks.dataProvider = event.result;
private function ResultEvent_UpdateTasks(event:ResultEvent):void{
Alert.show('Your task was updated');
private function showNewProject():void{
var newProjectWindow:IFlexDisplayObject =
PopUpManager.createPopUp(this, NewProject, true);
newProjectWindow.addEventListener(MouseEvent.CLICK, refreshProjects);
private function showNewTask():void{
var newTaskWindow:IFlexDisplayObject =
PopUpManager.createPopUp(this, NewTask, true);
private function dateFormat(item:Object, column:DataGridColumn):String{
return dateFormatter.format(item[column.dataField]);
//Function calls the Reason popup window
//private function changeReason():void{
//Create Popup Window
//var resultWindow:IFlexDisplayObject =
//PopUpManager.createPopUp(this, dateChangeNotice, false);
]]>
</mx:Script>
<mx:RemoteObject id="roGetData" destination="ColdFusion" source="projectTracker.components.cfc.controllers.getController">
<mx:method name="getProjects" result="ResultEvent_Projects(event);" fault="Alert.show(event.fault.faultString);" />
<mx:method name="getTasks" result="ResultEvent_Tasks(event);" fault="Alert.show(event.fault.faultString);" />
</mx:RemoteObject>
<!--<mx:RemoteObject id="roUpdateData" destination="ColdFusion" source="projectTracker.components.cfc.controllers.updateController">
<mx:method name="updateTasks" result="ResultEvent_UpdateTasks(event);" fault="Alert.show(event.fault.faultString);" />
</mx:RemoteObject>-->
<mx:DateFormatter id="dateFormatter" />
<mx:HBox width="100%">
<mx:Label text="Projects:" />
<mx:Button label="Insert New Project" click="showNewProject();"/>
</mx:HBox>
<mx:Panel width="100%" height="45%" title="Projects">
<mx:DataGrid id="dgProjects" width="100%" height="100%" itemClick="projectClick(event);" dataProvider="">
<mx:columns>
<mx:DataGridColumn dataField="projectID" headerText="ProjectID" visible="false" />- I Need to pass this value
<mx:DataGridColumn dataField="name" headerText="Project" />
<mx:DataGridColumn dataField="startDate" headerText="Date Started" labelFunction="dateFormat" />
<mx:DataGridColumn dataField="endDate" headerText="Completion Date" labelFunction="dateFormat" />
<mx:DataGridColumn dataField="description" headerText="Description" />
<mx:DataGridColumn dataField="statusName" headerText="Status" />
<mx:DataGridColumn dataField="ownerName" headerText="Owner" />
</mx:columns>
</mx:DataGrid>
</mx:Panel>
<mx:Panel width="100%" height="45%" title="Project Tasks">
<mx:AdvancedDataGrid id="adgTasks" width="95%" height="100%" variableRowHeight="true">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="taskID" visible="false" width="50" />
<mx:AdvancedDataGridColumn dataField="name" width="25" />
<!--<mx:AdvancedDataGridColumn dataField="startDate" headerText="Date Started" />
<mx:AdvancedDataGridColumn dataField="endDate" headerText="Completion Date" />-->
<mx:AdvancedDataGridColumn id="descript" dataField="description" headerText="Description" width="50"/>
<mx:AdvancedDataGridColumn dataField="ownerID" headerText="Owner" width="25" />
<mx:AdvancedDataGridColumn dataField="notes" headerText="Project Notes" width="50"/>
<mx:AdvancedDataGridColumn dataField="Dates" headerText="Dates" width="50"/>
</mx:columns>
<mx:rendererProviders>
<mx:AdvancedDataGridRendererProvider dataField="taskID" columnIndex="5">
<mx:renderer>
<mx:Component>
<mxml:dgDateHSlider startDate="{data.startDate}" endDate="{data.endDate}"/>
</mx:Component>
</mx:renderer>
</mx:AdvancedDataGridRendererProvider>
</mx:rendererProviders>
</mx:AdvancedDataGrid>
</mx:Panel>
<mx:HBox width="100%">
<mx:Label text="Tasks:" />
<mx:Button label="Insert New Task" click="showNewTask();"/>
<mx:Spacer width="200"/>
</mx:HBox>
</mx:VBox>
Popup Components
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="400" title="Reason for Date Change" backgroundColor="#E5E4E4">
<mx:Script>
<![CDATA[
import mx.events.ValidationResultEvent;
import mx.rpc.events.ResultEvent;
import mx.managers.PopUpManager;
import mx.core.IFlexDisplayObject;
import components.mxml.NewUser;
import mx.controls.Alert;
import components.mxml.Projects;
import components.mxml.NewTask;
//Clear Text Area Function
public function Clear():void{
reasonText.text = "";
//function to send notes to db via RO
public function writeNotes():void{
into here--> updateReason.reasonUpdate(taskID.selectedItem,reasonText.text); taskID.selectedItem is not recognized. It errors on compile
//remote object Results Event
public function reasonResult(event:ResultEvent):void{
Alert.show("Label update successful, thank you!");
Clear();
]]>
</mx:Script>
<!--Update Remote Object-->
<mx:RemoteObject id="updateReason" destination="ColdFusion" source="projectTracker.components.cfc.controllers.createController">
<mx:method name="reasonUpdate" result="reasonResult(event);" fault="Alert.show(event.fault.faultString);"/>
</mx:RemoteObject>
<!--Reason Text Area-->
<mx:TextArea x="19" y="60" width="90%" height="246" maxChars="1000" wordWrap="true" enabled="true" id="reasonText"/>
<mx:Button label="Update" click="writeNotes()" right="65" bottom="0"/>
<mx:Button label="Exit" click="PopUpManager.removePopUp(this);" right="10" bottom="0"/>
<mx:Text text="Please Specify your reason for changing the dates of this task." width="90%" fontWeight="bold" top="10" horizontalCenter="0"/>
</mx:TitleWindow> -
Help with Remoting in Flex 2 PLEASE!!!!
I can't figure out how to send data to a cfc from flex, using
my remoteObject.
I can send simple data, 1 or 2 params, but I need to send
data that is in a Model Object.
So here is my function that calls the remote edit function,
and tried to send the data that is sent in an event to the
function.
private function regUpdate(event:RegEdit):void{
var edit:Object = event.itemReturn;
//Alert.show(edit.level);
regService.editReg(edit);
When I call the editReg with the edit Object as a param, I
get this Error
faultCode:Server.Processing
faultSrting:'java.lang.StackOverflowError
faultDetail:'null'
In Flash remoting, I could just send an Object and then
access it in the cfc using Arguments.param
But I guess this is not the case for Flex.
But it doesn't seem to matter what is in my cfc, if I try and
pass that Object, it errors.
What am I missing? I have been searching for an answer to
this all morning, with no results.
Where are all the good Flex examples....
Please help
My project is due Monday!!!hmm, I guess I know less then I thought.
When you say ActionScript class that corresponds to the CFC,
what are you referencing?
I am calling the service from an mxml file. The data is
created in a sub componet of that mxml file, and passed to the
parent in an event.
Should I be storing my data in an .as file?
here is the code for the mxml file
<mx:Panel xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:is="components.reg.*" layout="horizontal"
title="Registrations" titleStyleName="ttl" initialize="init()">
<mx:Metadata>
[RemoteClass(alias="zrPortal.services.reg")]
</mx:Metadata>
<mx:Script>
<![CDATA[
import events.RegEdit;
import mx.collections.ArrayCollection;
import events.GridItemSelected;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
[Bindable]
private var regData:ArrayCollection;
[Bindable]
private var trekData:ArrayCollection;
[Bindable]
public var lInfo:Object;
[Bindable]
private var regItemData:Object;
public function init():void{
regService.getReg(lInfo.level,lInfo.rId);
public function handleRegResult(event:ResultEvent):void{
regData = event.result as ArrayCollection;
public function handleTrekResult(event:ResultEvent):void{
trekData = event.result as ArrayCollection;
private function regHandler(event:GridItemSelected):void{
regItemData = event.itemSelected;
trekService.getTreks(event.itemSelected.regId);
//edit function
private function regUpdate(event:RegEdit):void{
var edit:Object = event.itemReturn;
//Alert.show(edit.level);
regService.editReg(edit);
private function regAdd():void{
private function regDel():void{
]]>
</mx:Script>
<mx:RemoteObject
id="regService"
destination="ColdFusion"
source="zrPortal.services.reg"
showBusyCursor="true">
<mx:method name="getReg" result="handleRegResult(event)"
fault="Alert.show(event.fault.message)"/>
<mx:method name="editReg" result="handleRegResult(event)"
fault="Alert.show(event.fault.message)"/>
</mx:RemoteObject>
<mx:RemoteObject
id="trekService"
destination="ColdFusion"
source="zrPortal.services.RegTrek"
showBusyCursor="false">
<mx:method name="getTreks"
result="handleTrekResult(event)"
fault="Alert.show(event.fault.message)"/>
</mx:RemoteObject>
<is:RegList width="375" regData="{regData}"
itemSelected="regHandler(event)"/>
<mx:VBox>
<mx:LinkBar dataProvider="{regContent}"/>
<mx:ViewStack id="regContent"
x="0" y="5"
paddingBottom="0"
paddingLeft="0"
paddingRight="0"
paddingTop="0"
resizeToContent="true" width="100%">
<is:RegData id="regdata" label="Reg Data"
iData="{regItemData}" lInfo="{lInfo}" updateReg="regUpdate(event)"
addReg="regAdd()" deleteReg="regDel()"/>
<is:TrekData id="trekdata" label="Tec-Treks"
iData="{trekData}"/>
</mx:ViewStack>
<is:RegFooter id="footer" iData="{regItemData}"/>
</mx:VBox>
</mx:Panel> -
Hello everyone,
A major concern arises for me, and after several days of testing I can not find a solution.
I am currently developing a mobile application on Android to play a video locally.
For this I use the Adobe SimpleStageVideo class available on the website : http://www.adobe.com/devnet/flashplayer/articles/stage_video.html
At the launch all goes well , however when I switch to another application in full reading and then I go back to my video .
That passes over other elements of my interface (ie the navigation menu ) and especially it grows.
I tried to do a resize an event type activate ( to intercept the return on applicaiton )
I also tried to remove the container, and then reinject the video in my interface ( although this is costly in resources ... ) .
It did not work .
I think during my event "activate " the UIComponent has not yet been fully rebuilt, and thereby resize does not work on a good screen size used (since it does not blow conscidère menus ) .
To test my theory , I tested passing in debug mode. By running my code slower, the video goes back to the right size ...
So I tried to put timers, but again it was a futile attempt .
How is it possible when returning to my application that my video remains the right size , and not overlooking the rest of the menus?
Here follows the code in question :
// La Vue Permettant de Visionner la Vidéo
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:components="bouton.components.*"
xmlns:s="library://ns.adobe.com/flex/spark" title="viewVideo" activate="view1_activateHandler(event)" creationComplete="view1_creationCompleteHandler(event)" backgroundAlpha="0" actionBarVisible="false" tabBarVisible="false">
<fx:Script>
<![CDATA[
import flash.events.MouseEvent;
import mx.core.UIComponent;
import mx.events.FlexEvent;
import valueObjects.SimpleStageVideo;
private var conn:SQLConnection;
private var createStmt:SQLStatement;
public var dbFile:File;
public var fichierCharge:File;
public var numeroBouton:int = 0;
private var test:SimpleStageVideo = new SimpleStageVideo();
private var container:UIComponent = new UIComponent();
protected function view1_creationCompleteHandler(event:FlexEvent):void
var chemin:File = new File(data.url);
test.setData(chemin);
//container.stage = this.stage;
container.height = stage.height;
container.width = stage.width;
container.addChildAt(test, 0);
addElementAt(container, 0);
trace(""+container.width+" : "+container.height+" : "+container.x+" : "+container.y);
protected function view1_activateHandler(event:Event):void
test.resize();
private function resizeF(event:Event):void
test.resize();
]]>
</fx:Script>
<s:HGroup id="barremenu" gap="0" horizontalAlign="left" styleName="header_style" verticalAlign="top" width="100%" contentBackgroundColor="#FFFFFF" contentBackgroundAlpha="1" paddingBottom="50" >
<s:Image scaleMode="letterbox" smooth="true" smoothingQuality="high"
source="assets/header_droi.jpg" />
<components:Boutton_Retour click="boutton_retour1_clickHandler(event)" enabled="true" height="100%" contentBackgroundColor="#FFFFFF" contentBackgroundAlpha="1"/>
<components:Boutton_Accueil_Retour click="boutton_accueil1_clickHandler(event)" enabled="true" height="100%" contentBackgroundColor="#FFFFFF" contentBackgroundAlpha="1" />
<s:Image scaleMode="stretch" smooth="true" smoothingQuality="high"
source="assets/header_milieu.jpg" fillMode="repeat" width="60%" height="99%" />
<s:Image scaleMode="stretch" smooth="true" smoothingQuality="high"
source="assets/ipad.jpg" />
</s:HGroup>
</s:View>
// Ma Classe SimpleStageVideo
package valueObjects
import flash.display.Loader;
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.NetStatusEvent;
import flash.events.StageVideoAvailabilityEvent;
import flash.events.StageVideoEvent;
import flash.events.VideoEvent;
import flash.filesystem.File;
import flash.geom.Rectangle;
import flash.media.StageVideo;
import flash.media.StageVideoAvailability;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import mx.core.UIComponent;
import spark.components.Image;
import spark.components.NavigatorContent;
[SWF(frameRate="1", backgroundColor="#000000")]
public class SimpleStageVideo extends Sprite
public var chemin:File;
private var FILE_NAME:String = "";
private static const INTERVAL:Number = 500;
private static const BORDER:Number = 20;
private var legend:TextField = new TextField();
private var sv:StageVideo;
private var nc:NetConnection;
private var ns:NetStream;
private var rc:Rectangle;
private var video:Video;
private var thumb:Shape;
private var interactiveThumb:Sprite;
private var totalTime:Number;
private var videoWidth:int;
private var videoHeight:int;
private var outputBuffer:String = new String();
private var rect:Rectangle = new Rectangle(0, 0, 0, BORDER);
private var videoRect:Rectangle = new Rectangle(0, 0, 0, 0);
private var gotStage:Boolean;
private var stageVideoInUse:Boolean;
private var classicVideoInUse:Boolean;
private var accelerationType:String;
private var infos:String = new String();
private var available:Boolean;
private var inited:Boolean;
private var played:Boolean;
private var container:Sprite;
private var displayButtonPause:Boolean;
public var imagePause:UIComponent;
public var pLoad:Loader;
private var testResize:Boolean = false;
private var widthStage:int = 0;
public function SimpleStageVideo()
// Make sure the app is visible and stage available
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
//addEventListener(Event.ACTIVATE, onActivate);
private function onActivate(event:Event):void
video.addEventListener(Event.RENDER, functionResize);
private function functionResize(event:Event):void
resize();
* @param event
private function onAddedToStage(event:Event):void
// Scaling
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
widthStage = stage.width;
// Thumb seek Bar
thumb = new Shape();
interactiveThumb = new Sprite();
interactiveThumb.addChild(thumb);
addChild(interactiveThumb);
// Connections
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
ns.client = this;
// Screen
video = new Video();
video.smoothing = true;
// Video Events
// the StageVideoEvent.STAGE_VIDEO_STATE informs you if StageVideo is available or not
stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, onStageVideoState);
// in case of fallback to Video, we listen to the VideoEvent.RENDER_STATE event to handle resize properly and know about the acceleration mode running
video.addEventListener(VideoEvent.RENDER_STATE, videoStateChange);
// Input Events
stage.addEventListener(MouseEvent.DOUBLE_CLICK, onKeyDown);
stage.addEventListener(Event.RESIZE, onResize);
stage.addEventListener(MouseEvent.CLICK, onClick);
* @param event
private function onNetStatus(event:NetStatusEvent):void
if ( event.info == "NetStream.Play.StreamNotFound" )
legend.text = "Video file passed, not available!";
public function setData(chem:File):void
chemin = chem;
FILE_NAME = chemin.url;
* @param event
private function onFrame(event:Event):void
var ratio:Number = (ns.time / totalTime) * (widthStage+470);
rect.width = ratio;
thumb.graphics.clear();
thumb.graphics.beginFill(0xFF0000);
thumb.graphics.drawRect(rect.x, rect.y+350, rect.width+120, rect.height);
//thumb.graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
//testResize = true;
* @param event
private function onClick(event:MouseEvent):void
//ns.pause();
if ( event.stageY >= interactiveThumb.y - BORDER && event.stageX <= stage.stageWidth - BORDER )
var seekTime:Number = (stage.mouseX - BORDER) * ( totalTime / (stage.stageWidth - (BORDER << 1) ) );
ns.seek( seekTime );
* @param event
private function onKeyDown(event:MouseEvent):void
ns.togglePause();
// Affichage du bouton d'affichage de la mise en pause de la video
if(displayButtonPause == false)
pLoad = new Loader();
pLoad.load(new URLRequest("assets/pause.png"));
//imagePause = new UIComponent();
//imagePause.addChild(pLoad);
//imagePause.x = 200;
//imagePause.y = 200;
pLoad.x = (stage.width - (stage.width/3.5));
pLoad.y = (stage.height - (stage.height/3.5));
addChild(pLoad);
displayButtonPause = true;
pLoad.visible = true;
} else
displayButtonPause = false;
pLoad.visible = false;
removeChild(pLoad);
* Permet l'arret de la video avant la supression de la vue
public function arretVideo():void
//video.clear();
//sv.attachNetStream(null);
ns.close();
//video.attachNetStream(null);
/*var nce:NetConnection = new NetConnection();
nce.connect(null);
sv.attachNetStream(new NetStream(nce));
//sv.attachNetStream();*/
* @param width
* @param height
* @return
private function getVideoRect(width:uint, height:uint):Rectangle
trace("Width" + width);
trace("Stage Width" + stage.stageWidth);
trace("Height" + height);
trace("Stage height" + stage.stageHeight);
var videoWidth:uint = width;
var videoHeight:uint = height;
var scaling:Number = Math.min ( stage.stageWidth / videoWidth, stage.stageHeight / videoHeight );
videoWidth *= scaling, videoHeight *= scaling;
var posX:uint = stage.stageWidth - videoWidth >> 1;
var posY:uint = stage.stageHeight - videoHeight >> 1;
videoRect.x = posX;
videoRect.y = posY;
videoRect.width = videoWidth;
videoRect.height = videoHeight;
trace("Objet video width" + video.width);
trace("Objet video height" + video.height);
trace("Objet video rect width" + videoRect.width);
trace("Objet video rect height" + videoRect.height);
return videoRect;
public function resize ():void
if ( stageVideoInUse )
// Get the Viewport viewable rectangle
rc = getVideoRect(sv.videoWidth, sv.videoHeight);
// set the StageVideo size using the viewPort property
sv.viewPort = rc;
} else
// Get the Viewport viewable rectangle
rc = getVideoRect(video.videoWidth, video.videoHeight);
// Set the Video object size
video.width = rc.width;
video.height = rc.height;
video.x = rc.x, video.y = rc.y;
//trace(""+rc.width+" : "+rc.height+" : "+rc.x+" : "+rc.y);
testResize = true;
interactiveThumb.x = BORDER, interactiveThumb.y = stage.stageHeight - (BORDER << 1);
legend.text = infos;
* @param evt
public function onMetaData ( evt:Object ):void
totalTime = evt.duration;
stage.addEventListener(Event.ENTER_FRAME, onFrame);
* @param event
private function onStageVideoState(event:StageVideoAvailabilityEvent):void
// Detect if StageVideo is available and decide what to do in toggleStageVideo
toggleStageVideo(available = inited = (event.availability == StageVideoAvailability.AVAILABLE));
* @param on
private function toggleStageVideo(on:Boolean):void
infos = "StageVideo Running (Direct path) : " + on + "\n";
// If we choose StageVideo we attach the NetStream to StageVideo
if (on)
stageVideoInUse = true;
if ( sv == null )
sv = stage.stageVideos[0];
sv.addEventListener(StageVideoEvent.RENDER_STATE, stageVideoStateChange);
sv.attachNetStream(ns);
if (classicVideoInUse)
// If we use StageVideo, we just remove from the display list the Video object to avoid covering the StageVideo object (always in the background)
stage.removeChild ( video );
classicVideoInUse = false;
} else
// Otherwise we attach it to a Video object
if (stageVideoInUse)
stageVideoInUse = false;
classicVideoInUse = true;
video.attachNetStream(ns);
stage.addChildAt(video, 0);
if ( !played )
played = true;
ns.play(FILE_NAME);
* @param event
private function onResize(event:Event):void
resize();
* @param event
private function stageVideoStateChange(event:StageVideoEvent):void
infos += "StageVideoEvent received\n";
infos += "Render State : " + event.status + "\n";
trace(infos);
resize();
* @param event
private function videoStateChange(event:VideoEvent):void
infos += "VideoEvent received\n";
infos += "Render State : " + event.status + "\n";
trace(infos);
resize();Hi,
Don't know if this is an entirely valid answer as I write pure AS3 (no Flex).
I remember having problems about a year ago with the SimpleStageVideo when doing a video app that would work for both Apple and Android.
I couldn't get it to work as I wanted so I skipped SimpleStageVideo alltogether.
I ended up using this script to shift between StageVideo (iOS) and the usual videoPlayer (Android).
The stageVideo checks if a menu is open (on the left side) and draws the rect according to that.
The normal video gets it's size from the videoSprite which scales depending on the menu visibility.
Later when StageVideo became available for Android it still worked.
Hopefully it can help you get closer to a solution.
private function load_video():void{
if ( stage.stageVideos.length >= 1 ) {
stageVideo = stage.stageVideos[0];
try {
if(S.application.menu.toggleOpen == true){
stageVideo.viewPort = new Rectangle(S.device.scaledVideo.x, S.device.scaledVideo.y, S.device.scaledVideo.width, S.device.scaledVideo.height);
} else if(S.application.menu.toggleOpen == false){
stageVideo.viewPort = new Rectangle(S.device.video.x, S.device.video.y, S.device.video.width, S.device.video.height);
} catch(e:Error) {}
stageVideo.addEventListener(StageVideoEvent.RENDER_STATE, renderState);
stageVideo.attachNetStream(netStream);
} else {
try {
video = new Video(S.device.video.width, S.device.video.height);
video.smoothing = true
video.name = "video"
video.x = S.device.video.x
video.y = S.device.video.y
videoSprite.addChild(video);
video.attachNetStream(netStream);
} catch(e:Error) {}
netStream.play(S.path.video + S.application.xmlObjectArray[currentSlideIndex].video);
videoStarted = true
Maybe you are looking for
-
IDVD Problem with burning a DVD
Whenever I try to burn a DVD using iDVD, I get this message "Multiplexer Error: There was an error during building. This disc is still untouched and may be reused later." I've tried this with 3 different DVDs and keep getting this problem. Can so
-
After iphoto update i can't delete pictures
Yesterday after the new updtae i can't delete pictures and after some time iphoto gives nor respones. can someone help please? sorry for bad english
-
When i click save button the data get cleared
Hi All, I am using oracle Apps r12 and forms 10g. I have a form when the user enters the data and click save option the data get cleared in the form and asked the user to enter to reenter the data again.Can any pls tell me the reason behind this.I ha
-
Hi, Is there any FM to find the manager of a person. I have the Managers Pernr . Thank you
-
Hi All: I would like to try this Abode Acrobat XI Pro (can you only get a trial for the Pro version) I before i buy just the regular Acrobat XI. How do i find a serial bumber for the trail version. Thanks for any help