Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 6:46 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Flex / Master Pages / Scripts / Load & Execute order
PostPosted: March 10th, 2013, 11:44 am 
Offline

Joined: July 12th, 2009, 10:33 am
Posts: 124
Hello

I've just spent about 5 hours trying to find the cause of what seemed like an illogical problem, so thought I would share it. I have found a workaround but would really like more info as to what is actually going on. The issue was that scripts placed in a master page were not accessible from an activity page when published to flex. The solution was to move or delete a seemily unrelated and unused page. I've attached a mockup of the problem with the following pages.

1. Master Page with scripts.
2. Initiate page (just forwards to the Activity Page in the test, but connects to our server and retrieves player info in real version).
3. Problem Page (completely blank in the test, but moving it still solves the issue. In the real version, this is a number of pages)
4. Activity Page.

Strangely enough, with the 'Problem Page' in place, the Onshow scripts in the Master Page don't run, and the Activity Page can't access the other scripts placed there either. Moving the problem page to the end or deleting it (even though it is completely empty in my test file) solves all the problems. Well this is the case on my machine, anyway.

In my mockup, the master page onshow script should place a red circle on the screen, and pressing the 3rd button should run a script stored in the master page and give the answer 6.

I can use this work around, but it will create lots more work in the future so I would prefer to find a solution. There doesn't seem to be anywhere to add a delay that has an affect.

Would appreciate any thoughts if you have time.
Thanks
Dan


You do not have the required permissions to view the files attached to this post.

_________________
V9.6. Windows 10. Testing on PC, Mac, iPad.


For this message dan1 has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Flex / Master Pages / Scripts / Load & Execute order
PostPosted: March 10th, 2013, 12:58 pm 
Offline

Joined: July 12th, 2009, 10:33 am
Posts: 124
Actually, even my workaround doesn't necessarily work.

_________________
V9.6. Windows 10. Testing on PC, Mac, iPad.


For this message dan1 has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Flex / Master Pages / Scripts / Load & Execute order
PostPosted: March 10th, 2013, 7:02 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Dan,
Just a general response. IIRC, something in the help files mentioned that in Flex type Pubs:
1. scripts execute at once, or immediately -- or something to that effect.
2. scripts inside developer-defined functions are not accessible or cannot be used by Flex.

...I do not know if the above are true statements or are correctly stated -- I'm just going from some old memory of what I thought I read.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Flex / Master Pages / Scripts / Load & Execute order
PostPosted: March 10th, 2013, 10:16 pm 
Offline

Joined: July 12th, 2009, 10:33 am
Posts: 124
Thanks Lar. There are certainly limitations and differences with scripts in Flex, but this is an odd issue.

For example, forget master pages. If you copy a script object into 5 different pages in a publication, it is only available to the first of these pages. This kind of defeats the point in using them in the first place.

I think I'm going to have to back-peddle and return to opus functions where poss. The problem with these is that if you have a lot of mouse-overs repeatedly showing an object with some common functions in it, then you get visual delays and jerky movements when using the activity. Scripts solved that problem, but....

I'm presuming V8 doesn't do anything differently here.

Cheers

_________________
V9.6. Windows 10. Testing on PC, Mac, iPad.


For this message dan1 has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Flex / Master Pages / Scripts / Load & Execute order
PostPosted: March 11th, 2013, 12:54 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
dan1 wrote:
If you copy a script object into 5 different pages in a publication, it is only available to the first of these pages. This kind of defeats the point in using them in the first place.
I just did a test on this. I created a Flex Type Pub with 3 pages. The scripts in the script object on each page did execute.

The only thing about the scripts is as the Help files state... the commands run immediately. (consult the Help file for actual wording/instructions on this -- for example, an object Rotate(720,3,true) did rotate in 3 sec. However, my other MoveX and MoveY actions executed upon page load and did not wait for any of the inserted wait(2) commands, nor did these wait for the Rotate action to complete.

This was Win Vista, Opus 7.x, Flex Pub and tested by publishing. I did not try a Master Page.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Flex / Master Pages / Scripts / Load & Execute order
PostPosted: March 11th, 2013, 12:57 pm 
Offline

Joined: July 12th, 2009, 10:33 am
Posts: 124
Here's my workaround should anyone need it. The reason I use this, btw, is that I have about a hundred files with different activities but a common set of backgrounds and scripts. If I change a script or action, then I can just copy the master page into each file. The alternative is editing each file individually, which takes forever.

- If you have only one activity page in a file, then you can use external scripts in either the activity or a master page.

- If you have more than one activity page in a file, then you can't access external scripts in anything other than the first, wherever you store them. You can place the scripts in an internal script object, without the function declaration, in an activity page or master page. The script is placed under an OnShow trigger and the object hides itself after 0s. You can show this object from anywhere to call the script (akthough it may have to be from another internal script).

- If you are using external scripts, then place any other pages (a 'Task Completed' page in my case) at the end of the file. Positioning it higher up can stop external scripts working altogether.

Cheers
Dan

_________________
V9.6. Windows 10. Testing on PC, Mac, iPad.


For this message dan1 has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Flex / Master Pages / Scripts / Load & Execute order
PostPosted: March 11th, 2013, 1:04 pm 
Offline

Joined: July 12th, 2009, 10:33 am
Posts: 124
That's wierd Lar. They were functions in external scripts?

My test is attached. Each page is identical. The 1st button runs an internal script. The 2nd runs an external script stored in the page. The 3rd runs an external script stored in the master page.

The internal always works.
The page script works only on the first page it exists in.
The MP script never works in this, unless you delete the 'Problem Page'.

Cheers
Dan


You do not have the required permissions to view the files attached to this post.

_________________
V9.6. Windows 10. Testing on PC, Mac, iPad.


For this message dan1 has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Flex / Master Pages / Scripts / Load & Execute order
PostPosted: March 11th, 2013, 7:26 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Quote:
They were functions in external scripts?
No, I did not use developer-defined functions. All code in a Script Object. Just a simple script sequence:
Code:
wait(2)
Vec01.MoveX(200)
wait(2)
Vec01.MoveY(200)
For Page 2, I simply duplicated Page 1 AND modified the script to move a different object called Vec03. Page 3 was a duplicated page, and its Vector being rotated and moved was Vec05. In all cases, the wait delays were ignored and the MoveX and MoveY seemed to occur simultaneously.

I tried only this simple direct approach. I doubt I will have time today, buy later might play with Functions or maybe glance at your test pub.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Flex / Master Pages / Scripts / Load & Execute order
PostPosted: March 11th, 2013, 7:35 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
dan1 wrote:
Here's my workaround should anyone need it.
I wonder if some other LOGIC workarounds might orchestrate things the way you want. You could try setting or using some variable with different values on different pages, then using Swith/Case or IF conditionals. You'll have to be clever -- figure out how to create Triggers that can run the script, or rather call the Function, sometime after page load. Maybe a timeline? Maybe a user event? Maybe a variable-changed and a ticker?

I do not use Flex currently, so am not inclined myself to go very far experimenting.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Flex / Master Pages / Scripts / Load & Execute order
PostPosted: March 11th, 2013, 10:16 pm 
Offline

Joined: July 12th, 2009, 10:33 am
Posts: 124
Cheers Lar. My workarounds will do for now.

It's all about workload for me. It is a large music site and I have to keep pages in separate SWF files otherwise the sounds make them too large for quick download. I use master pages and external scripts to reduce the workload when making common changes to all the files. It was just a nightmare to get to the bottom of this one because a number of seemingly unrelated factors lead to a specific problem. It's done now so I'm moving on.

Many thanks for having a think about it :)

_________________
V9.6. Windows 10. Testing on PC, Mac, iPad.


For this message dan1 has been thanked by : mackavi


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 72 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group