A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Delegate class... Help!

  1. #1
    Junior Member
    Join Date
    Nov 2005
    Posts
    14

    Unhappy Delegate class... Help!

    Hi there,

    I have not found any reason for it, but the Delegate class doesn't appear to work in Flash Lite, any version. Here is my code:

    Code:
    function x_onLoad(result:Boolean)
    {
    	trace("x_onLoad FUNCTION CALLED");
    	if (result)
    	{
    		trace("SUCCESS!");
    	}
    
    }
    
    var x:XML = new XML();
    x.onLoad = Delegate.create(this, x_onLoad);
    x.load("db/questions.xml");
    My trace in Device Central is:
    Code:
    FTPS033: A Call to loadVariables(db/questions.xml) found, limitations might apply.
    Connected to file://C:\Work\test\bin\db\questions.xml.
    Loaded data from file://C:\Work\test\bin\db\questions.xml.
    Finished request for file://C:\Work\test\bin\db\questions.xml.
    However, if I don't use Delegate (which, I might add, is a right pain in the @ss):

    Code:
    var x:XML = new XML();
    
    x.onLoad = function(result:Boolean)
    {
    	trace("x.onLoad function called");
    	if(result)
    	{
    	trace("SUCCESS!");
    	}
    };
    x.load("db/questions.xml");
    It works fine:
    Code:
    FTPS033: A Call to loadVariables(db/questions.xml) found, limitations might apply.
    Connected to file://C:\Work\test\bin\db\questions.xml.
    Loaded data from file://C:\Work\test\bin\db\questions.xml.
    Finished request for file://C:\Work\test\bin\db\questions.xml.
    x.onLoad function called
    SUCCESS!
    Anyone got any clues? I can't find anything else on the web about Delegate not working in Flash Lite. Surely it's just a simple AS2.0 class?

    Thanks!

    :-Joe

  2. #2
    Junior Member
    Join Date
    Nov 2005
    Posts
    14

    Cool

    Hello all again,

    Just by posting this message I have noticed what was happening... And it's a weird one! It's all working perfectly... It's just that for some STRANGE reason, when Flash Lite hits a LoadVars-type event, the Output window in Flash STOPS tracing:

    Code:
    StartupCommand
    StartupViewCommand
    DebugMediator:_level0.debug
    FPSComponent
    FPSComponent:_level0.debug.FPSComponent
    StartupModelCommand
    LoadQuestionsCommand::execute
    _questionProxy:[object Object]
    FTPS033: A Call to loadVariables(db/questions.xml) found, limitations might apply.
    Connected to file://C:Worktestndbquestions.xml.
    Loaded data from file://C:Worktestndbquestions.xml.
    Finished request for file://C:Worktestindbquestions.xml.
    Since I was looking at that Output window and not the one in Device Central, I assumed it wasn't working. However the Output window in Device Central does report all the traces I was expecting:
    Code:
    StartupCommand
    StartupViewCommand
    DebugMediator:_level0.debug
    FPSComponent
    FPSComponent:_level0.debug.FPSComponent
    StartupModelCommand
    LoadQuestionsCommand::execute
    _questionProxy:[object Object]
    FTPS033: A Call to loadVariables(db/questions.xml) found, limitations might apply.
    Connected to file://C:\Work\test\bin\db\questions.xml.
    Loaded data from file://C:\Work\test\bin\db\questions.xml.
    Finished request for file://C:\Work\test\bin\db\questions.xml.
    LoadQuestionsCommand::onLoad
    NextQuestionCommand::execute
    [object Object]
    0
    <question id="0"><subject>maths</subject><tag>mobile</tag><title><text>A dice is thrown 80 times. it lands on a six 12 times. What is the probability of throwing a six?</text></title><option id="A"><text>1/6</text></option><option id="B"><text>3/20</text></option><option id="C"><text>4/12</text></option><option id="D"><text>3/6</text></option><answer>B</answer></question>
    hooray!!

    I thought I'd post my findings here just in case someone else comes up against this oddity... You never know! I just have to remember to keep looking at the Output window in DC from now on and not the one in Flash!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center