I have an application compiled in Flex 4.5 and I load (with SWFLoader) other application compiled in Flex 3.5, it works fine but when I execute the sentence "SystemManager(myLoader.content)" the system shows the error:
TypeError: Error #1034: Error de conversión forzada: no se puede convertir _AnalizaOrganigramaTest_mx_managers_SystemManager#8450eb9 en mx.managers.SystemManager.
at AnaTestModule/_mlCargada()[C:\eanaliza\branch\peticiones3_p9184\40 flex\flex\AnaTestModule\src\AnaTestModule.mxml:28]
at AnaTestModule/__myLoader_complete()[C:\eanaliza\branch\peticiones3_p9184\40 flex\flex\AnaTestModule\src\AnaTestModule.mxml:43]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:13128]
at mx.controls::SWFLoader/http://www.adobe.com/2006/flex/mx/internal::contentLoaderInfo_completeEventHandler()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\controls\SWFLoader.as:2292]
This is Flex 4.5 application code:
<fx:Script>
<![CDATA[
import mx.managers.SystemManager;
[Bindable]
public var loadedSM:SystemManager;
protected function _mlInit():void
{
myLoader.source = "/analiza_peticiones3_p9184/AnalizaOrganigramaTest-debug/AnalizaOrganigramaTest.swf";
myLoader.load();
}
private function _mlCargada():void
{
loadedSM = SystemManager(myLoader.content);
}
]]>
</fx:Script>
<s:SWFLoader id="myLoader"
loadForCompatibility="true"
complete="_mlCargada();"
maintainAspectRatio="true"
scaleContent="false"
/>
Can anyone help me?
Thanks in advance.
I've been working on something similar to this. Try using LoaderMax from GreenSock.
http://www.greensock.com/loadermax/
Im using a multiversioned sub application in mine and tried SystemManager as well, this lead to nowhere and I went back to LoaderMax. I was getting way too many RSL loading errors and whatnot using SystemManager.
you might also be running into the need for Marshalling support.
The parent App is SDK 4.5, this shares two SWC files (4.5) with another application (4.6)
The parent app loads an SDK 4.1 application into itself.
This is working for the most part, I am still trouble shooting linked assets and relative paths. But all in all, the application loads.
In the parent application view screen to load the child app:
[Bindable] private var childAppLink= "http://myserver.com/AppRoot/##version/controls/Application.swf";
[Bindable] private var altChildAppLink:String = "/AppRoot/##version/controls/Application.swf";
[Bindable] private var loaderQueue:LoaderMax = new LoaderMax({name:"ChildApp4_0_Loader",onProgress:handleLoaderProgress,onComplete:handleLoaderComplete,onError:handleLoadingError});
protected function loadUsingLoaderMax():void
{
childAppLink= StringUtils.replace(childAppLink,'##version',cm.s.childAppVersion);
altChildAppLink= StringUtils.replace(altChildAppLink,'##version',cm.s.childAppVersion);
var swfvars:SWFLoaderVars = new SWFLoaderVars();
var loaderRequest:URLRequest = new URLRequest();
var loaderVars:URLVariables = new URLVariables();
var loaderContexts:LoaderContext = new LoaderContext();
LoaderMax.contentDisplayClass = FlexContentDisplay;
loaderVars.DEBUG = cm.s.debug;
loaderVars.inChildMode = "true"; //set this as a string!
loaderVars.bpu = String(u.userId + ';' + u.currentLocationId);
loaderVars.sv = cm.s.childAppVersion;
loaderVars.KEYWORD = 'XXXXX';
loaderContexts.applicationDomain = new ApplicationDomain();
if(Security.sandboxType == Security.REMOTE)
loaderContexts.securityDomain = SecurityDomain.currentDomain;
loaderRequest.url = childAppLink;
loaderRequest.data = loaderVars;
loaderRequest.method = URLRequestMethod.GET;
swfvars.name("ChildApplication_4_0");
swfvars.estimatedBytes(410000000);
swfvars.container(ChildAppPH);
swfvars.x(0);
swfvars.autoPlay(true);
swfvars.scaleMode("none");
swfvars.alternateURL(altChildAppLink);
swfvars.context(loaderContexts);
loaderQueue.append(new com.greensock.loading.SWFLoader(loaderRequest,swfvars) );
this.addEventListener("mx.managers.SystemManager.isBootstrapRoot", systemManagerHandler);
this.addEventListener("mx.managers.SystemManager.isStageRoot", systemManagerHandler);
ShoplandPlaceholder.systemManager.addEventListener(FlexEvent.CREATION_COMPLETE,handleLoaderComplete);
loaderQueue.load();
ChildAppPH.visible = false;
ChildAppPH.alpha = 0;
}
protected function systemManagerHandler(event:Event):void
{
event.preventDefault();
}
and the MXML for the placeholder:
<s:SWFLoader id="ChildAppPH" width="1010" height="610" verticalCenter="305" horizontalCenter="505" top="10" />
The child application is setup to handle some new flashvars (this.parameters) which tell it what to do in its loading procedures. the child app is a standalone and can function without this, so it has now become a dual purpose application. 1) standalone, 2) child app (inChildMode)
Related
I tried to make sqlite delete data process from adobe flash builder 4.6 but i can not success.i have below error.Other codes and things ok.i use datagrid component.The last code that i edited below:
protected function buton_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
function seckayit():void{
var sec:SQLStatement=new SQLStatement;
sec.sqlConnection=conn;
sec.text="SELECT * FROM deneme";
sec.execute();
sec.addEventListener(SQLEvent.RESULT,silkayit);
function silkayit(event:SQLResult):void{
stmt.sqlConnection = conn;
stmt.text="";
//contactList.removeAll();
stmt.text="DELETE FROM deneme WHERE id='"+liste.selectedItem.id+"'";
stmt.execute();
}
}
}
and my mxml code is:
<s:Button x="206" y="-2" label="Kayıt Sil" click="silkayit(event)"/>
I have this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at views::listviewHomeView/silkayit()[C:\Users\mobil-developer\Adobe Flash Builder 4.6\veri-islem\src\sec.as:68]
at views::listviewHomeView/___listviewHomeView_Button1_click()[C:\Users\mobil-developer\Adobe Flash Builder 4.6\veri-islem\src\views\listviewHomeView.mxml:16]
where did i make mistake?What must i do? Would you like to help me?
I've developed a simple flex app with embedded swf. Basically swf use Loadvars to get data from particular database table. Ok, when I tested the flex app on localhost it is works fine and embedded swf make its sendAndLoad calls correctly.
But! When it is located on the web server swf not work correctly. I meant there is not returned values by sendAndLoad method.
Well, to make some points: questionContentLoadVars.img1 holds(return) the string from php call. This "img1" is an empty returned string only in Flex app placed in the web server otherwise it returns correct value from php call?
When gameplay22.swf is standallone works!
When gameplay22.swf is in HTML page works!
When gameplay22.swf is embedded in FLex and executed in LOCALHOST works!
But in the web server this embedded gameplay22.swf doesn`t works!
What is the problem with it?
//* here is flash(swf) part of gameplay22.swf file which is embedded in the Flex by SWFLOader(gameplay22.swf)
questionContentLoadVars = new LoadVars();
questionContentLoadVars.onLoad = function(success){
if (success){
slidingSvityk_mc.descripTA_mc.description_ta.text = questionContentLoadVars.theContent;
}
else
{
slidingSvityk_mc.description_ta.text = "err!";
}
};
function loadQuestionData(sectionID){
var tablename ='questionsgeo'; // database tablename
//sending variables to the PHP script
questionContentLoadVars.row = sectionID;
questionContentLoadVars.tablename = tablename;
questionContentLoadVars.id_ = "";
questionContentLoadVars.img1 = "";
questionContentLoadVars.sendAndLoad("getQuestionRec.php",questionContentLoadVars,"_POST");
};
function showLoadedGalleryImages():Void{
infphp.text = questionContentLoadVars.img1;
var img1Bulk:MovieClip = new MovieClip();
img1Bulk = imgGalleryContainer_mc.img1Bulck_mc.createEmptyMovieClip(img1Bulk, _root.getNextHighestDepth());
img1Bulk._x = 0;
img1Bulk._y = 0;
image_mcl.loadClip(questionContentLoadVars.img1, img1Bulk);
};
//* And here is Flex part of embedded SWFLOader(gameplay22.swf) component
<s:SWFLoader includeIn="user" width="1024" height="768" horizontalCenter="0" source="gameplay22.swf" verticalCenter="0"/>
I have flex project where i want to call webservice and pass values from it to the xml file to update fusion chart xml
My code is
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
public var PUENumber:String;
protected var xmlLoader:URLLoader;
[Bindable]
public var avgPUEXml:XML = new XML;
protected function init():void
{
xmlLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE,setDataXML)
xmlLoader.load(new URLRequest("data/AvgPUE.xml")); //Loading xml file for the chart from the folder
};
protected function setDataXML(event:Event):void
{
avgPUEXml = XML(event.target.data);
avgPUEXml.value = PUENumber; //updating chart xml value
fw.FCDataXML = avgPUEXml.toString();
fw.FCRender();
};
protected function getDC_POWERdataResult_resultHandler(event:ResultEvent):void
{
PUENumber = getDC_POWERdataResult.lastResult; //getting value to update in xml file
init();
}
protected function bordercontainer1_creationCompleteHandler(event:FlexEvent):void
{
getDC_POWERdataResult.token = mGEMWS.getDCPUE("4","715"); //user details to get data from the method
}
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id="getDC_POWERdataResult" result="getDC_POWERdataResult_resultHandler(event)"/>
<mgemws:MGEMWS id="mGEMWS" showBusyCursor="true"
fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"/>
</fx:Declarations>
<ns1:FusionWidgets id="fw" FCChartType="Bulb" FCDataXML="avgPUEXml" />
in the declaration am calling web service. and on creationCompelete am sending userid details to get data from webservice. now where exactly i need to call init function so that it updates xml file with values coming from web service and display the fusion widget
You don't need the 'setDataXML' handler method. Also you don't need any 'URLLoader' or 'URLRequest' in the 'init' method. FusionCharts supports XML data as well as XML path. So remove the 'setDataXML' and remove all the codes from the 'init' method and add just fw.addEventListener(FCEvent.FCRenderEvent, wgdtRendHandler);
and add below handler method -
protected function wgdtRendHandler(e:FCEvent):void{
e.target.FCSetDataURL='data/AvgPUE.xml';
e.target.removeEventHandler(FCEvent.FCRenderEvent, wgdRendHandler);
}
I think this should work for you. In case you still don't get the updated data in the chart, check the XML file in the 'init' method whether it's updated properly at that point of time.
You can call the init function when the chart finishes loading and is ready for data.
You can do this listening to FCLoadEvent or FCRenderEvent of the gauge.
Please try using :
<ns1:FusionWidgets id="fw" FCChartType="Bulb" FCDataXML="avgPUEXml" FCRenderEvent="init()"/>
or
<ns1:FusionWidgets id="fw" FCChartType="Bulb" FCDataXML="avgPUEXml" FCLoadEvent="init()"/>
my client want to have all resources embedded into the Main SWF which i create with Flex. The UI itself origins form a .FLA that must have timeline actionscript (AS3). After I embed the SWF there seems to be NO timeline AS in the embedded SWF. Is this possible to solve?
I Embed like this:
public var templ: TemplateBase;
[Embed(source="images/template_banner.swf", mimeType="application/octet-stream")]
public var TemplateSWF:Class;
...
var ba : ByteArray = new TemplateSWF() as ByteArray;
var l : Loader = new Loader();
l.loadBytes(ba);
l.addEventListener(Event.ADDED_TO_STAGE, onTemplateAdd);
addChild(l);
private function onTemplateAdd(evt:Event):void{
templ = evt.target.contentLoaderInfo.content;
}
In template_banner.swf there is a stop(); in frame 1, and some code in frame 2.
I trace in both frames but nothing is showing in the Flex (4) debugger.
After the swf is added to stage I do play() in the TemplateBase class.
The thing is that play and all the AS code in the loaded SWF is totally dead.
My question is: Is there a way to keep the timeline AS code in the embedde SWF? And yes I need to embed the SWF into the Flex main file :/
Thanks,
Rob
From what I'm seeing in the code, you are doing loadBytes which is asynchronous... and then waiting to the ADDED_TO_STAGE, and in the event listener you are accessing the content...
Because the loadBytes is asynchronous, you should wait for the loading to complete.
In the complete listener you should access the loaded content.
I would totally avoid the ADDED_TO_STAGE.
do it like this:
public var templ: TemplateBase;
[Embed(source="images/template_banner.swf", mimeType="application/octet-stream")]
public var TemplateSWF:Class;
var ba : ByteArray = new TemplateSWF() as ByteArray;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader.loadBytes(ba);
private function completeHandler(event:Event):void {
templ = evt.target.contentLoaderInfo.content;
}
I'm having a problem with labels disappearing on Flex's datavisualization.swc charts that are built on our build server via ANT and the Flex 3.3 SDK. I've made sure that our license is applied properly on the build server (hence no water marks), and I've made sure the exact same datavisualization.swc was copied from my dev machine into the Flex3.3SDK/frameworks/libs directory.
Any ideas? Could it be a font problem? (Though we're really only using default fonts.)
Here's the problem, missing axis labels on the build server
alt text http://img687.imageshack.us/img687/5038/chartwithmissingaxislab.png
Here's how it's supposed to look with labels (taken on my local development machine)
alt text http://img683.imageshack.us/img683/1504/chartwithaxislabels.png
I got it working using the helpful information I found at the Flex Coders archive.
Basically, in an initalize event handler, I added the following code:
var ccClassFactory:ContextualClassFactory = new ContextualClassFactory(ChartAxisTextLabel);
ccClassFactory.moduleFactory=this.moduleFactory;
var hAxisRenderer:AxisRenderer = new AxisRenderer();
hAxisRenderer.axis = hAxis;
hAxisRenderer.labelRenderer=ccClassFactory;
var vAxisRenderer:AxisRenderer = new AxisRenderer();
vAxisRenderer.axis = vertAxis;
vAxisRenderer.labelRenderer=ccClassFactory;
lineChart.horizontalAxis=hAxis;
lineChart.verticalAxis=vertAxis;
lineChart.horizontalAxisRenderers = [ hAxisRenderer ];
lineChart.verticalAxisRenderers = [ vAxisRenderer ];
Also, I had to create the class:
public class ChartAxisTextLabel extends Label
{
public function ChartAxisTextLabel()
{
super();
}
override public function set data(value:Object):void
{
super.data = value;
text = value.text;
}
}