firefox can't follow the link, in other browsers all right - hyperlink

Ggo to https://codepen.io/anon/pen/pVGXZG hover mouse on NAV and try click on "firefox"
Other browser when you click on "firefox" following link without problem
var btn = document.getElementById("main-btn");
btn.addEventListener("mouseover", function (e) {
var nav = document.getElementById("main-nav");
var sub_btns = document.getElementsByClassName("sub-btn");
var pos = [];
e.className += "main-hover";
console.log(e)
nav.addEventListener("mouseover", function (e) {
var total =0;
for(var x = 0;x<sub_btns.length;x++) {
if(x <2) {
sub_btns[x].style.left = "-"+((x+1)*30)+"%";
pos[x] = ((x+1)*20);
} else {
sub_btns[x].style.right = "-"+((x-1)*30)+"%";
pos[x] = ((x-1)*280);
}
sub_btns[x].style.opacity = "1";
}
nav.style.width = 50+"%";
});
nav.addEventListener("mouseout", function(){
nav.style.width = "100px";
for(var x = 0;x<sub_btns.length;x++) {
sub_btns[x].style.left = "0";
sub_btns[x].style.right = "0";
sub_btns[x].style.opacity = "0";
}
})
});

Spec says, that inside of you can have only phrasing content. That is, the element inside won't be interactive (clickable).

Related

for embedded PDFs, can PDFJS support both scrolling and jump to a page number at the same time?

This seems like it should be very standard behavior.
I can display a scrollable PDF with:
var container = document.getElementById('viewerContainer');
var pdfViewer = new PDFJS.PDFViewer({
container: container,
});
PDFJS.getDocument(DEFAULT_URL).then(function (pdfDocument) {
pdfViewer.setDocument(pdfDocument);
});
and I can display the PDF page by page with something like:
PDFJS.getDocument(URL_ANNOTATED_PDF_EXAMPLE).then(function getPdfHelloWorld(pdf) {
pdf.getPage(pageNumber).then(function getPageHelloWorld(page) {
var scale = 1.5;
var viewport = page.getViewport(scale);
var canvas = document.getElementById('the-canvas');
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
var renderContext = {
canvasContext: context,
viewport: viewport
};
page.render(renderContext);
});
But can't seem to find any reference in the API to both allow scrolling and jumping to a particular page, besides:
pdfViewer.currentPageNumber = 3;
which doesn't work...
So I found a way to make this work (mixed with a little Angular code, "$scope.$watch...") I now have other problems with font decoding. But here is a solution that might help someone else.
var me = this;
PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK;
var container = document.getElementById('capso-court-document__container');
function renderPDF(url, container) {
function renderPage(page) {
var SCALE = 1;
var pdfPageView = new PDFJS.PDFPageView({
container: container,
id: page.pageIndex + 1,
scale: SCALE,
defaultViewport: page.getViewport(SCALE),
textLayerFactory: new PDFJS.DefaultTextLayerFactory(),
annotationLayerFactory: new PDFJS.DefaultAnnotationLayerFactory()
});
pdfPageView.setPdfPage(page);
return pdfPageView.draw();
}
function renderPages(pdfDoc) {
var pageLoadPromises = [];
for (var num = 1; num <= pdfDoc.numPages; num++) {
pageLoadPromises.push(pdfDoc.getPage(num).then(renderPage));
}
return $q.all(pageLoadPromises);
}
PDFJS.disableWorker = true;
return PDFJS.getDocument(url)
.then(renderPages);
}
$scope.$watch(function() {
return {
filingUrl: me.filingUrl,
whenPageSelected: me.whenPageSelected,
};
}, function(newVal, oldVal) {
if (newVal.filingUrl) {
//newVal.filingUrl = URL_EXAMPLE_PDF_ANNOTATED;
//newVal.filingUrl = URL_EXAMPLE_PDF_ANNOTATED_2;
//newVal.filingUrl = URL_EXAMPLE_PDF_MULTI_PAGE;
if (newVal.filingUrl !== oldVal.filingUrl &&
newVal.whenPageSelected &&
newVal.whenPageSelected.page) {
scrollToPage(newVal.whenPageSelected.page);
}
//HACK - create new container for each newly displayed PDF
container.innerHTML = '';
var newContainerForNewPdfSelection = document.createElement('div');
container.appendChild(newContainerForNewPdfSelection);
renderPDF(newVal.filingUrl, newContainerForNewPdfSelection).then(function() {
if (newVal.whenPageSelected &&
newVal.whenPageSelected.page) {
scrollToPage(newVal.whenPageSelected.page);
}
});
}
}, true);
function scrollToPage(pageNumber) {
var pageContainer = document.getElementById('pageContainer' + pageNumber);
if (pageContainer) {
container.scrollTop = pageContainer.offsetTop;
} else {
console.warn('pdf pageContainer doesn\'t exist for index', pageNumber);
}
}

Detecting TabMove in firefox add-on

Tried out the impl. given in : https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Tabbed_browser#Notification when a tab is added or removed
for tracking 'tabmove'. Didn't work.
Would appreciate any help in this regard.
BTW, already tried below code. Only 'TabOpen' event is received. 'TabClose' and 'TabMove' does not work:
var browserWindows = require("sdk/windows").browserWindows;
var activeWindow = browserWindows ? browserWindows.activeWindow : {};
var browserWindow = activeWindow ? require("sdk/view/core").viewFor(activeWindow) : {};
var DOMWindow = browserWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
var exampleTabAdded = function(event) {
var browser = DOMWindow.gBrowser.getBrowserForTab(event.target);
console.log('tab added: '+ event.target);
};
var exampleTabMoved = function(event) {
var browser = DOMWindow.gBrowser.getBrowserForTab(event.target);
console.log('tab moved: '+ event.target);
};
function exampleTabRemoved(event) {
var browser = gBrowser.getBrowserForTab(event.target);
console.log('tab removed: '+ event.target);
}
function exampleTabSelected(event) {
var browser = gBrowser.getBrowserForTab(event.target);
console.log('tab selected: '+ event.target);
}
var container = DOMWindow.gBrowser.tabContainer;
container.addEventListener("TabMove", exampleTabMoved, false);
container.addEventListener("TabOpen", exampleTabAdded, false);
container.addEventListener("TabClose", exampleTabRemoved, false);
container.addEventListener("TabSelect", exampleTabSelected, false);
Thanks
This seems to work. Uses both sdk api's as well as XUL content document.
If there is a better way to handle 'tabmove', please do post the answer.
var tabs = require("sdk/tabs");
var { modelFor } = require("sdk/model/core");
var { viewFor } = require("sdk/view/core");
var tab_utils = require("sdk/tabs/utils");
var contentDocumentMap = new Map();
function mapHighLevelTabToLowLevelContentDocument(tab) {
var lowLevelTab = viewFor(tab);
var browser = tab_utils.getBrowserForTab(lowLevelTab);
return browser.contentDocument;
}
function onOpen(tab) {
tab.on("pageshow", logShow);
tab.on("activate", logActivate);
tab.on("deactivate", logDeactivate);
tab.on("close", logClose);
}
function logShow(tab) {
var contentWindow = mapHighLevelTabToLowLevelContentDocument(tab);
if ((contentWindow.URL === 'about:newtab') || (contentWindow.URL === 'about:blank')) {
return;
}
if (contentDocumentMap.has(contentWindow)) {
return;
}
contentDocumentMap.set(contentWindow, tab.id.toString());
}
function logActivate(tab) {
var contentWindow = mapHighLevelTabToLowLevelContentDocument(tab);
if ((contentWindow.URL === 'about:newtab') || (contentWindow.URL === 'about:blank')) {
return;
}
if (contentDocumentMap.has(contentWindow)) {
return;
}
contentDocumentMap.set(contentWindow, tab.id.toString());
}
function logDeactivate(tab) {
setTimeout(function() {
var windows = require("sdk/windows").browserWindows;
for (let window of windows) {
var activeTabContentWindow = mapHighLevelTabToLowLevelContentDocument(window.tabs.activeTab);
var activeTabId = window.tabs.activeTab.id.toString();
if ((contentDocumentMap.has(activeTabContentWindow)) && (contentDocumentMap.get(activeTabContentWindow) !== activeTabId)) {
console.log('M O V E D. url: '+ window.tabs.activeTab.url);
console.log('from tabid: '+ contentDocumentMap.get(activeTabContentWindow) + ' to tabid: ' + activeTabId);
contentDocumentMap.delete(activeTabContentWindow);
contentDocumentMap.set(activeTabContentWindow, activeTabId);
}
}
}, 150);
}
function logClose(tab) {
var targetTabId = tab.id.toString();
setTimeout(function() {
var windows = require("sdk/windows").browserWindows;
for (let window of windows) {
var activeTabContentWindow = mapHighLevelTabToLowLevelContentDocument(window.tabs.activeTab);
var activeTabId = window.tabs.activeTab.id.toString();
if (contentDocumentMap.has(activeTabContentWindow)) {
if (contentDocumentMap.get(activeTabContentWindow) !== activeTabId) {
console.log('M O V E D. url: '+ window.tabs.activeTab.url);
console.log('from tabid: '+ contentDocumentMap.get(activeTabContentWindow) + ' to tabid: ' + activeTabId);
contentDocumentMap.delete(activeTabContentWindow);
contentDocumentMap.set(activeTabContentWindow, activeTabId);
}
else if (targetTabId === activeTabId){
contentDocumentMap.delete(activeTabContentWindow);
}
}
}
}, 150);
}
tabs.on('open', onOpen);

jquery: focus jumps before event runs

The focus moves to the next input field before the event is fired. Can anyone help me find the bug, or figure out how to find it myself?
The goal is to catch the keyup event, verify that it is tab or shift+tab, and then tab as though it were tabbing through a table. When the focus gets to the last input that is visible, the three rows (see fiddle for visual) should move together to reveal hidden inputs. Once to the end of the inputs in that row, the three rows will slide back down to the beginning again, kind of like a carriage return on a typewriter, or tabbing into a different row in a table.
Right now, the tab event is moving just the row that holds the focus, and it is moving it before my script even starts to run. I just need to know why this is happening so that I can research how to resolve it.
Any help you can offer is appreciated. Please let me know if you need more information.
P.S. Using jquery 1.9.1
Link to Fiddle
jQuery(document).ready(function ($) {
// bind listeners to time input fields
//$('.timeBlock').blur(validateHrs);
$('.timeBlock').keyup(function () {
var caller = $(this);
var obj = new LayoutObj(caller);
if (event.keyCode === 9) {
if (event.shiftKey) {
obj.dir = 'prev';
}
obj.navDates();
}
});
// bind listeners to prev/next buttons
$('.previous, .next').on('click', function () {
var str = $(this).attr('class');
var caller = $(this);
var obj = new LayoutObj(caller);
obj.src = 'pg';
if (str === 'previous') {
obj.dir = 'prev';
}
obj.navDates();
});
});
function LayoutObj(input) {
var today = new Date();
var thisMonth = today.getMonth();
var thisDate = today.getDate();
var dateStr = '';
var fullDates = $('.dateNum');
var splitDates = new Array();
this.currIndex = 0; //currIndex defaults to 0
this.todayIndex;
fullDates.each(function (index) {
splitDates[index] = $(this).text().split('/');
});
//traverse the list of dates in the pay period, compare values and stop when/if you find today
for (var i = 0; i < splitDates.length; i++) {
if (thisMonth === (parseInt(splitDates[i][0], 10) - 1) && thisDate === parseInt(splitDates[i][1], 10)) {
thisMonth += 1;
thisMonth += '';
thisDate += '';
if (thisMonth.length < 2) {
dateStr = "0" + thisMonth + "/";
}
else {
dateStr = thisMonth + "/";
}
if (thisDate.length < 2) {
dateStr += "0" + thisDate;
}
else {
dateStr += thisDate;
}
fullDates[i].parentNode.setAttribute('class', 'date today');
this.todayIndex = i;
break;
}
}
//grab all of the lists & the inputs
this.window = $('div.timeViewList');
this.allLists = $('.timeViewList ul');
this.inputs = $('.timeBlock');
//if input`isn't null, set currIndex to match index of caller
if (input !== null) {
this.currIndex = this.inputs.index(input);
}
//else if today is in the pay period, set currIndex to todayIndex
else if (this.todayIndex !== undefined) {
this.currIndex = this.todayIndex;
}
//(else default = 0)
//grab the offsets for the cell, parent, and lists.
this.winOffset = this.window.offset().left;
this.cellOffset = this.inputs.eq(this.currIndex).offset().left;
this.listOffset = this.inputs.offset().left;
//grab the width of a cell, the parent, and lists
this.cellWidth = this.inputs.outerWidth();
this.listWidth = this.inputs.last().offset().left + this.cellWidth - this.inputs.eq(0).offset().left;
this.winWidth = this.window.outerWidth();
//calculate the maximum (left) offset between the lists and the parents
this.offsetMax = (this.listWidth - this.winWidth);
//set default scroll direction as fwd, and default nav as tab
this.dir = 'next';
this.src = 'tab';
//grab the offsets for the cell, parent, and lists.
this.cellOffset = this.inputs.eq(this.currIndex).offset().left;
this.listOffset = this.inputs.eq(0).offset().left;
this.winOffset = this.allLists.parent().offset().left;
//calculate the maximum (left) offset between the lists and the parents
this.offsetMax = (this.listWidth - this.winWidth);
}
LayoutObj.prototype.focusDate = function () {
this.inputs.eq(this.currIndex).focus();
};
LayoutObj.prototype.slideLists = function (num) {
this.listOffset += num;
this.allLists.offset({ left: this.listOffset });
};
LayoutObj.prototype.navDates = function () {
if (!this.inWindow()) {
var slide = 0;
switch (this.src) {
case 'pg':
slide = this.winWidth - this.cellWidth;
break;
case 'tab':
slide = this.cellWidth + 1;
break;
default:
break;
}
if (this.dir === 'next') {
slide = -slide;
}
this.slideLists(slide);
}
this.focusDate();
};
LayoutObj.prototype.inWindow = function () {
//detects if cell intended for focus is visible in the parent div
if ((this.cellOffset > this.winOffset) && ((this.cellOffset + this.cellWidth) < (this.winOffset + this.winWidth))) {
return true;
}
else {
return false;
}
}
All it needed was 'keydown()' instead of 'keyup().'

Bookmarklet to invoke onChange from actionlist in Safari on iPad

My work uses a proprietary system to store medical records. The site is coded in javascript, and we are unable to change the coding of the site. We would like to use iPads to access the site, the site is accessed through a browser which is serving HTML.
There is a drop-down list that has an onChange value, which when an item is selected from the drop-down list onChange="doAction(this)" is invoked. This works fine in a desktop browser, however the iPad doesn't support the onChange. I know that an alternative is to use onBlue, however we do not have access to change the HTML.
What I was hoping we could do was to add a bookmarklet that once clicked, in principle does what the onChange event did.
The current actionlist HTML is:
<select class="actionList" onChange="doAction(this)" style="width:100%"><option class="actionHeading" selected value="nothing">Select action ..</option><option class="action" value="moreInfo"> More Info (shortcut key ' i ')</option><option class="actionHeading" disabled>Add Electronic Form ..</option><option class="action" value="xform-progressnotes-amendment-discharge"> Amendment Discharge Summary</option><option class="action" value="xform-progressnotes-clinical-review"> Clinical Review</option><option class="action" value="xform-dischargesummary"> Discharge Summary</option><option class="action" value="xform-progressnotes-family-work"> Family Work</option><option class="action" value="xform-progressnotes-medical-review"> Medical Review</option><option class="action" value="xform-medicationsummary"> Medication Summary Form</option><option class="action" value="xform-operationrecord"> Operation Sheet</option><option class="action" value="xform-progressnotes-inpatient"> Progress Notes</option><option class="action" value="xform-progressnotes-weekly-summary"> Weekly Summary</option></select></td>
The only option I would like to have in the bookmarklet is to 'select' the medical review option, i.e
<option class="action" value="xform-progressnotes-medical-review"> Medical Review</option>
the javascript for onChange="doAction(this)" is:
function doAction(selectObj)
{
var xformPrefix = 'xform-';
var chartPrefix = 'chart-';
var action = selectObj.value;
selectObj.selectedIndex = 0;
if (action == 'moreInfo')
{
moreInfo();
}
else if (action == 'referForAttn')
{
referForAttn();
}
else if(action.startsWith(chartPrefix)) {
var chartName = action.substring(chartPrefix.length);
var url;
var processedURL;
var checkExistUrl = '/udr/json/?action=chartsdescription';
checkExistUrl += '&patientId=630402';
checkExistUrl += '&chartName=' + chartName;
$.ajax({
async:false,
dataType:"json",
url:checkExistUrl,
success:function(data){
if(data.description != "")
{
var answer = confirm(data.description);
}
if(answer || data.description == "")
{
}
}
});
}
else if (action.startsWith(xformPrefix))
{
var xformName = action.substring(xformPrefix.length);
var url;
var windowWidth;
var windowHeight;
var processedURL;
if (xformName == 'progressnotes-amendment-discharge')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=progressnotes-amendment-discharge&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dprogressnotes-amendment-discharge%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 500;
}
if (xformName == 'progressnotes-clinical-review')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=progressnotes-clinical-review&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dprogressnotes-clinical-review%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 500;
}
if (xformName == 'dischargesummary')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=dischargesummary&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Ddischargesummary%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 550;
}
if (xformName == 'progressnotes-family-work')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=progressnotes-family-work&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dprogressnotes-family-work%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 500;
}
if (xformName == 'progressnotes-medical-review')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=progressnotes-medical-review&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dprogressnotes-medical-review%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 500;
}
if (xformName == 'medicationsummary')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=medicationsummary&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dmedicationsummary%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 760;
}
if (xformName == 'operationrecord')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=operationrecord&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Doperationrecord%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 760;
}
if (xformName == 'progressnotes-inpatient')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=progressnotes-inpatient&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dprogressnotes-inpatient%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 500;
}
if (xformName == 'progressnotes-weekly-summary')
{
url = '/oip-forms-viewer/forms/templates?udrSessionId=BF0C3C8399163439782C67D2757477DC&formName=progressnotes-weekly-summary&patientId=630402&episodeId=458698&transactionId=&xformAction=new&sectionId=Admission';
processedURL = '%2Foip-forms-viewer%2Fforms%2Ftemplates%3FudrSessionId%3DBF0C3C8399163439782C67D2757477DC%26formName%3Dprogressnotes-weekly-summary%26patientId%3D630402%26episodeId%3D458698%26transactionId%3D%26xformAction%3Dnew%26sectionId%3DAdmission'
windowWidth = 800;
windowHeight = 500;
}
var newForm;
var confirmMsg = "There is another e-form opened. \n";
confirmMsg += "Press \"Cancel\" to finish editing the open e-form\n";
confirmMsg += "Press \"OK\" to discard it and open a new one.";
try {
var location = findFrame(top, 'main').win.document.location;
newForm = confirm(confirmMsg);
}
catch(e) {
newForm = true;
}
if(newForm) {
try {
findFrame(top, 'main').win.close();
}
catch(e) {}
findFrame(top, 'main').win = openCentredWindow(url, 'xformWindow', windowWidth, windowHeight);
try {
// setting the window title change on window load
$(findFrame(top, 'main').win).load(changeEformWindowTitle);
}
catch(e) {
// nothing to report
}
try {
// trying to change the window title early if the on load hasn't worked
setTimeout('changeEformWindowTitle()', 2000);
}
catch(e) {
// nothing to report
}
try {
// doing it a second time in case the first attempt was too early.
setTimeout('changeEformWindowTitle()', 8000);
}
catch(e) {
// nothing to report
}
try {
// doing it a third time 40 seconds later in case it there was a pre-fill.
setTimeout('changeEformWindowTitle()', 40000);
}
catch(e) {
// nothing to report
}
}
else {
findFrame(top, 'main').win.focus();
}
}
}
Any help you could provide would be very much appreciated!
Thanks.
Your best bet is to place a proxy server between the ipad and the actual product.
This proxy can then modify the html generated by the proprietary system.
You can look into nginx as a newbie friendly solution for proxying.
Cheers,
T.
PS : I dont believe bookmarklets work on iPads. Even if they did, it would be a terrible UI.

AS2 TweenLite: tween to frame

I have the following setup loaded:
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
TweenPlugin.activate([FramePlugin]);
OverwriteManager.init(OverwriteManager.AUTO);
and am using the following code to tween an mc to frame 20.
TweenLite.to(circle, 1, {frame:20, ease:Elastic.easeOut});
Problem is nothing happens, circle is a variable containing my mc and traces fine.
Output of
trace(circle); = _level0.circle
Can anyone see why this isn't working? The MC contains a shapetween.
Edit:
Ok so I have tested it in a new fla with the same MC and it isn't the MC that is the problem it has to do with some other part of my code preventing it.
Here is my entire code... can anyone see anything that would stop the tween to frame working? If I remove for (MovieClip in txts) {
txts[MovieClip]._alpha = 0;
} and put the tween above it it works, but as soon as it is inside a rollover again it doesn't.
Entire code:
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
TweenPlugin.activate([ColorTransformPlugin, FramePlugin]);
OverwriteManager.init(OverwriteManager.AUTO);
var angle:Number = 0;
var originX:Number = Stage.width/2;
var originY:Number = Stage.height/2;
var radiusX:Number = 320.5;
var radiusY:Number = 247.5;
var steps:Number = 360;
var speed:Number = 0.4/steps;
var circle:MovieClip = this.circle;
var circleTxt:MovieClip = this.circle.titleTxt;
var squareHeight:Number = 340.2;
var buttons:Array = new Array(this.faith, this.social, this.ability, this.age, this.orientation, this.ethnicity, this.sex);
var txts:Array = new Array("faithTxt", "socialTxt", "abilityTxt", "ageTxt", "orientationTxt", "ethnicityTxt", "sexTxt");
var tweens:Array = new Array();
for (MovieClip in txts) {
txts[MovieClip]._alpha = 0;
}
for (i=0; i<buttons.length; i++) {
buttons[i].onRollOver = function() {
var current:MovieClip = this;
circle.onEnterFrame = function() {
if (this._currentframe == 20) {
delete this.onEnterFrame;
delete circleTxt.onEnterFrame;
current.txt._alpha = 100;
}
};
noScale(circleTxt);
txtName = current._name+"Txt";
current.txt = this._parent.attachMovie(txtName, txtName, this._parent.getNextHighestDepth());
current.txt._alpha = 0;
circle.txtHeight = circle.active.txt._height/2+40;
var oppX:Number = Stage.width-this._x;
var oppY:Number = Stage.height-this._y;
if (oppX-227.8<=20) {
var difference:Number = Math.abs(20-(oppX-227.8));
oppX += difference;
} else if (oppX+227.8>=Stage.width-20) {
var difference:Number = Math.abs(780-(oppX+227.8));
oppX -= difference;
}
if (oppY-172.1<=20) {
var difference:Number = Math.abs(20-(oppY-172.1));
oppY += difference;
} else if (oppY+172.1>=580) {
var difference:Number = Math.abs(580-(oppY+172.1));
oppY -= difference;
}
circle.active.txt._x = oppX;
circle.active.txt._y = oppY;
TweenLite.to(circle,1,{frame:20});
TweenLite.to(circle,0.5,{_height:circle.txtHeight});
TweenLite.to(circle,1,{_x:oppX, _y:oppY, ease:Quint.easeInOut});
TweenLite.to(circleTxt,1,{_alpha:0});
TweenLite.to(this,0.5,{colorTransform:{tint:0x99ff00, tintAmount:0.5}});
for (MovieClip in buttons) {
delete buttons[MovieClip].onEnterFrame;
if (buttons[MovieClip] != this) {
TweenLite.to(buttons[MovieClip],0.5,{colorTransform:{tint:0xffffff, tintAmount:0.9}});
TweenLite.to(buttons[MovieClip]._line,0.5,{colorTransform:{tint:0xffffff, tintAmount:0.9}});
}
}
};
buttons[i].onRollOut = function() {
removeMovieClip(this.txt);
circle.onEnterFrame = function() {
if (this._currentframe == 1) {
delete this.onEnterFrame;
delete circleTxt.onEnterFrame;
}
};
noScale(circleTxt);
TweenLite.to(circle,0.2,{_height:173});
TweenLite.to(circle,0.5,{_x:Stage.width/2, _y:Stage.height/2});
TweenLite.to(circleTxt,1,{_alpha:100});
for (MovieClip in buttons) {
buttons[MovieClip].onEnterFrame = function() {
moveButtons(this);
controlButtons(this);
};
TweenLite.to(buttons[MovieClip],0.5,{colorTransform:{tint:null, tintAmount:0}});
TweenLite.to(buttons[MovieClip]._line,0.5,{colorTransform:{tint:null, tintAmount:0}});
}
};
buttons[i].onEnterFrame = function() {
moveButtons(this);
controlButtons(this);
};
buttons[i]._order = (360/buttons.length)*1000+(i+1);
buttons[i]._linedepth = buttons[i].getDepth()-1000;
}
function noScale(mc) {
mc.onEnterFrame = function() {
this._yscale = 10000/this._parent._yscale;
};
}
function moveButtons(e) {
var lineName:String = new String(e._name+"line");
var lineMC:MovieClip = createEmptyMovieClip(lineName, e._linedepth);
with (lineMC) {
beginFill();
lineStyle(2,0x000000,100);
moveTo(e._x,e._y);
lineTo(Stage.width/2,Stage.height/2);
endFill();
}
e.rotation = Math.atan2(e._y-Stage.height/2, e._x-Stage.width/2);
e._line.dist = Math.sqrt(Math.abs(e._x-Stage.width/2) ^ 2+Math.abs(e._y-Stage.height/2) ^ 2);
e._line = lineMC;
e._anglePhase = (angle+e._order)/Math.PI*2.8;
e._x = originX+Math.sin(e._anglePhase)*radiusX;
e._y = originY+Math.cos(e._anglePhase)*radiusY;
}
function controlButtons(e) {
angle += speed;
if (angle>=360) {
angle -= 360;
}
}
Heh Solved, for some reason it doesn't like for (MovieClip in Array){} anywhere in your code, so if I substitute that for for (a in Array){} it seems to work. Odd.

Resources